diff --git a/.github/actions/jira-transition-tickets/scripts/extract-issue-keys.sh b/.github/actions/jira-transition-tickets/scripts/extract-issue-keys.sh index 8c8c33b..cb09213 100755 --- a/.github/actions/jira-transition-tickets/scripts/extract-issue-keys.sh +++ b/.github/actions/jira-transition-tickets/scripts/extract-issue-keys.sh @@ -10,7 +10,8 @@ if [[ -n "$MERGED_BRANCHES" ]]; then IFS=',' read -ra BRANCHES <<< "$MERGED_BRANCHES" for branch in "${BRANCHES[@]}"; do # Trim leading/trailing whitespace from branch name - branch=$(echo "$branch" | xargs) + branch="${branch#"${branch%%[![:space:]]*}"}" + branch="${branch%"${branch##*[![:space:]]}"}" while IFS= read -r key; do JIRA_KEYS+=("$key") done < <(echo "$branch" | grep -oE '[A-Z0-9]+-[0-9]+') diff --git a/.github/actions/jira-transition-tickets/test/test_extract-issue-keys.bats b/.github/actions/jira-transition-tickets/test/test_extract-issue-keys.bats index 876b4d8..8f3b6ed 100644 --- a/.github/actions/jira-transition-tickets/test/test_extract-issue-keys.bats +++ b/.github/actions/jira-transition-tickets/test/test_extract-issue-keys.bats @@ -183,3 +183,18 @@ teardown() { [ "$status" -eq 0 ] [ "$(grep '^issue_keys=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "PROJ25-123,PROJ25-456" ] } + +@test "extract-issue-keys: handles single quotes" { + run "$BATS_TEST_DIRNAME/../scripts/extract-issue-keys.sh" "Merge remote-tracking branch 'origin/develop, feature/PROJ-1011-eaa-login, futuredapp/feature/PROJ-1009-eaa-intro" + + [ "$status" -eq 0 ] + [ "$(grep '^issue_keys=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "PROJ-1009,PROJ-1011" ] +} + +@test "extract-issue-keys: handles double quotes" { + run "$BATS_TEST_DIRNAME/../scripts/extract-issue-keys.sh" "Merge remote-tracking branch 'origin/develop', feature/PROJ-1011-eaa-login, futuredapp/feature/PROJ-1009-eaa-intro" + + [ "$status" -eq 0 ] + [ "$(grep '^issue_keys=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "PROJ-1009,PROJ-1011" ] +} +