Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: scan commit body for issue keys #32

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: scan commit body for issue keys
  • Loading branch information
martinvysnovsky committed Oct 11, 2023
commit 1eea2e882c6c8a0aecc678b7fd4bbcbf21a38f5e
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