Created
June 15, 2017 10:50
-
-
Save sokil/f1e6e185765b5875abf83d4ace90a92d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| branchName=`git rev-parse --abbrev-ref HEAD` | |
| taskNumber=`echo $branchName | awk -F'-' '{print $4 "-" $5}'` | |
| taskSubject=`echo $branchName | awk -F'-' '{print $6}' | sed 's/_/ /g'` | |
| commitMessageFile=$1 | |
| commitMode=$2 | |
| messageInFile=`cat $commitMessageFile` | |
| # $2 is the commit mode | |
| # if $2 == 'commit' => user used `git commit` | |
| # if $2 == 'message' => user used `git commit -m '...'` | |
| if [ "$commitMode" = "message" ]; then | |
| echo -n "[$taskNumber][$taskSubject] - " > $commitMessageFile | |
| echo $messageInFile >> $commitMessageFile | |
| else | |
| firstLine=`head -n1 $commitMessageFile` | |
| # We check the fist line of the commit message file. | |
| # If it's an empty string then user didn't use `git commit --amend` so we can fill the commit msg file | |
| if [ -z "$firstLine" ]; then | |
| echo "[$taskNumber][$taskSubject] - " > $commitMessageFile | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment