Last active
June 12, 2023 10:04
-
-
Save mikalai-yankouski/5c7195bea22aabb8cb1a75933adff28b to your computer and use it in GitHub Desktop.
prepared message for commit
This file contains 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/bash | |
branchPath=$(git symbolic-ref -q HEAD | grep -Eo 'LENS-[0-9]+') #Somthing like refs/heads/myBranchName | |
branchName=$branchPath #Get text behind the last / of the branch path | |
firstLine=$(head -n1 $1) | |
if [ -z "$firstLine" ] ;then #Check that this is not an amend by checking that the first line is empty | |
sed -i "1s/^/$branchName \n/" $1 #Insert branch name at the start of the commit message file | |
fi | |
#mac | |
#!/bin/bash | |
branchPath=$(git symbolic-ref -q HEAD | grep -Eo 'CAGG-[0-9]+|CCMPSAPP-[0-9]+') #Somthing like refs/heads/myBranchName | |
branchName=$branchPath #Get text behind the last / of the branch path | |
firstLine=$(head -n1 $1) | |
if [ -z "$firstLine" ] ;then #Check that this is not an amend by checking that the first line is empty | |
sed -i '.bak' "1s/^/$branchName /" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment