Skip to content

Commit

Permalink
feat: scan commit body for issue keys (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvysnovsky authored Oct 12, 2023
1 parent 97a0253 commit 6c20f9c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/scripts/notify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ getIssueKeys() {
BRANCH_KEYS="$(parseKeys "$CIRCLE_BRANCH")"
local COMMIT_KEYS
COMMIT_KEYS="$(parseKeys "$COMMIT_MESSAGE")"
BODY_KEYS="$(parseKeys "$COMMIT_BODY")"
log "GETTING TAG KEYS"
local TAG_KEYS
TAG_KEYS="$(getTagKeys)"

# Check if the parsed keys are not empty before adding to the array.
[[ -n "$BRANCH_KEYS" ]] && KEY_ARRAY+=("$BRANCH_KEYS")
[[ -n "$COMMIT_KEYS" ]] && KEY_ARRAY+=("$COMMIT_KEYS")
[[ -n "$BODY_KEYS" ]] && KEY_ARRAY+=("$BODY_KEYS")
[[ -n "$TAG_KEYS" ]] && KEY_ARRAY+=("$TAG_KEYS")

# Remove duplicates
Expand All @@ -107,6 +109,7 @@ getIssueKeys() {
local message="No issue keys found in branch, commit message, or tag"
local dbgmessage=" Branch: $CIRCLE_BRANCH\n"
dbgmessage+=" Commit: $COMMIT_MESSAGE\n"
dbgmessage+=" Body: $COMMIT_BODY\n"
dbgmessage+=" Tag: $(git tag --points-at HEAD -l --format='%(tag) %(subject)' )\n"
echo "$message"
echo -e "$dbgmessage"
Expand Down Expand Up @@ -237,6 +240,7 @@ TIME_EPOCH=$(date +%s)
TIME_STAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
# JIRA_DEBUG_TEST_COMMIT is only used in testing
COMMIT_MESSAGE=$(git show -s --format='%s' "${JIRA_DEBUG_TEST_COMMIT:-$CIRCLE_SHA1}")
COMMIT_BODY=$(git show -s --format='%b' "${JIRA_DEBUG_TEST_COMMIT:-$CIRCLE_SHA1}")
JIRA_BUILD_STATUS=$(cat /tmp/circleci_jira_status)
PROJECT_VCS=""
PROJECT_SLUG=""
Expand Down Expand Up @@ -264,6 +268,7 @@ export JIRA_VAL_PIPELINE_NUMBER
export TIME_EPOCH
export TIME_STAMP
export COMMIT_MESSAGE
export COMMIT_BODY
export JIRA_BUILD_STATUS
export PROJECT_SLUG
export JIRA_PIPELINE_URL
Expand Down

0 comments on commit 6c20f9c

Please sign in to comment.