Skip to content

Commit

Permalink
Merge pull request #185 from City-of-Helsinki/UHF-X-fix-fixup-commits
Browse files Browse the repository at this point in the history
UHF-X: allow fixup commits
  • Loading branch information
hyrsky authored Nov 13, 2023
2 parents 79409fd + 3b75225 commit 7da4064
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# feature/PROJECT-1234-test-test
# PROJECT-1234-test-test
# PROJECT-1234_test_test
# fixup! (for git rebase --autosquash)
id=$(echo `git rev-parse --abbrev-ref HEAD` | sed -nE 's|([a-z]+/)?([A-Z]+-[0-9]+)(-.+)?(_.+)?|\2|p')
COMMIT_MESSAGE=$(cat $1)

# Only prepare commit message if pattern matched and Jira ID was found and
# message doesn't contain Jira ID already.
if [[ ! -z $id ]] && [[ $COMMIT_MESSAGE != $id* ]]; then
if [[ ! -z $id ]] && [[ $COMMIT_MESSAGE != $id* ]] && [[ $COMMIT_MESSAGE != "fixup!"* ]]; then
# $1 is the name of the file containing the commit message
# Prepend "ABCD-123: "
sed -i.bak -E "1s/^/${id}: /" $1
Expand Down

0 comments on commit 7da4064

Please sign in to comment.