Skip to content

Instantly share code, notes, and snippets.

@vardars
Created May 28, 2017 07:43
Show Gist options
  • Save vardars/1c191aa249b97200382d4d4f17ea3598 to your computer and use it in GitHub Desktop.
Save vardars/1c191aa249b97200382d4d4f17ea3598 to your computer and use it in GitHub Desktop.
Windows git hook commit message
#!/usr/bin/env python
import sys, re
from subprocess import check_output
branch = check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip()
commit_msg_filepath = sys.argv[1]
with open(commit_msg_filepath, 'r') as f:
content = f.read()
with open(commit_msg_filepath, 'w') as f:
f.write(branch + " - " + content)
#!/bin/sh
python .git/hooks/commit-message.py $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment