From 512ab3aeed2656cae6e43ad8a3caa8c6e29f0807 Mon Sep 17 00:00:00 2001 From: Sam Benskin <1180089+sambenskin@users.noreply.github.com> Date: Wed, 19 Feb 2025 09:31:36 +0000 Subject: [PATCH] Adding a check if commit message already starts with the issue key Adding a check if commit message already starts with the issue key --- scripts/prepare-commit-jira.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/prepare-commit-jira.sh b/scripts/prepare-commit-jira.sh index 788f31bc..ac7ec3b2 100644 --- a/scripts/prepare-commit-jira.sh +++ b/scripts/prepare-commit-jira.sh @@ -47,9 +47,8 @@ if [ $? -eq 0 ]; then exit fi - -# issue key matched from branch prefix, prepend to commit message -sed -i -e "1s/^/$ISSUE_KEY /" $1 - - - +# Check if commit message already starts with the issue key +if ! grep -q "^$ISSUE_KEY " "$1"; then + # issue key matched from branch prefix and not already present, prepend to commit message + sed -i -e "1s/^/$ISSUE_KEY /" "$1" +fi