Skip to content

Instantly share code, notes, and snippets.

@alper
Last active June 19, 2019 08:41
Show Gist options
  • Save alper/22aadce3015cb15c3eafc667cdf4ae79 to your computer and use it in GitHub Desktop.
Save alper/22aadce3015cb15c3eafc667cdf4ae79 to your computer and use it in GitHub Desktop.
A git hook that checks whether there is an issue number in the first line of your commit message
#!/usr/bin/env python3
import sys
commit_msg_filepath = sys.argv[1]
with open(commit_msg_filepath, 'r+') as fh:
lines = fh.readlines()
if '#' not in lines[0]:
print("No issue number in first line of commit message. Stopping.")
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment