From 791e40224328bdb98866619f2cb1ad427ba8f038 Mon Sep 17 00:00:00 2001 From: Artur Klamborowski Date: Thu, 5 Nov 2020 11:20:40 +0100 Subject: [PATCH 1/6] Use full commit body --- step.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/step.sh b/step.sh index 2ac65f7..131506d 100755 --- a/step.sh +++ b/step.sh @@ -9,7 +9,7 @@ magenta=$'\e[35m' cyan=$'\e[36m' reset=$'\e[0m' -MERGES=$(git log $(git merge-base --octopus $(git log -1 --merges --pretty=format:%P))..$(git log -1 --merges --pretty=format:%H) --pretty=format:%s) +MERGES=$(git log $(git merge-base --octopus $(git log -1 --merges --pretty=format:%P))..$(git log -1 --merges --pretty=format:%H) --pretty=format:%B) SAVEDIFS=$IFS IFS=$'\n' @@ -18,7 +18,8 @@ MERGES=($MERGES) IFS=$SAVEDIFS -LAST_COMMIT=$(git log -1 --pretty=format:%s) +LAST_COMMIT=$(git log -1 --pretty=format:%B) +LAST_COMMIT_SUBJECT=$(git log -1 --pretty=format:%s) TASKS=() @@ -37,7 +38,7 @@ then echo "${reset}" - if [ "$LAST_COMMIT" = "${MERGES[0]}" ]; + if [ "$LAST_COMMIT_SUBJECT" = "${MERGES[0]}" ]; then echo "${green}βœ… Merge commit detected. Searching for tasks in merge commits messages...${cyan}" for (( i=0 ; i<${#MERGES[*]} ; ++i )) @@ -45,7 +46,7 @@ then echo $'\t'"πŸ“œ "${MERGES[$i]} done - for task in $(echo $MERGES | grep "$project_prefix[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) + for task in $(echo ${MERGES[*]} | grep "$project_prefix[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) do TASKS+=($task) done @@ -53,7 +54,7 @@ then echo "${magenta}β˜‘οΈ Not a merge commit. Searching for tasks in current commit message...${cyan}" echo echo $'\t'"πŸ“œ "$LAST_COMMIT "${reset}" - + for task in $(echo $LAST_COMMIT | grep "$project_prefix[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) do TASKS+=($task) From ed60891a2f95931450f1c9528979ccf18f97eff1 Mon Sep 17 00:00:00 2001 From: Artur Klamborowski Date: Thu, 5 Nov 2020 18:54:10 +0100 Subject: [PATCH 2/6] Remove duplicates from tasks list --- step.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/step.sh b/step.sh index 131506d..8b667ed 100755 --- a/step.sh +++ b/step.sh @@ -62,7 +62,17 @@ then fi fi +echo "${reset}" +echo "${blue}πŸ“™ Tasks:${reset}" +echo "${TASKS[*]}" +echo "${green}βš™ Removing duplicates:${reset}" +TASKS=($(printf '%s\n' "${TASKS[@]}" | sort -u )) +echo "${TASKS[*]}" +echo "${reset}" + echo "${blue}βœ‰οΈ Comment:${cyan}" +echo "$jira_comment" +echo "${reset}" escaped_jira_comment=$(echo "$jira_comment" | perl -pe 's/\n/\\n/g' | sed 's/.\{2\}$//') From f3bdbead40b5a8b25e5c8158e9a2c8b73d9b4a11 Mon Sep 17 00:00:00 2001 From: Artur Klamborowski Date: Fri, 6 Nov 2020 09:42:21 +0100 Subject: [PATCH 3/6] Add multiple projects support --- step.sh | 34 ++++++++++++++++++++++++++-------- step.yml | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/step.sh b/step.sh index 8b667ed..b74d73e 100755 --- a/step.sh +++ b/step.sh @@ -18,11 +18,23 @@ MERGES=($MERGES) IFS=$SAVEDIFS +SAVEDIFS=$IFS +IFS=$'|' + +PROJECT_PREFIXES=($project_prefix) + +IFS=$SAVEDIFS + LAST_COMMIT=$(git log -1 --pretty=format:%B) LAST_COMMIT_SUBJECT=$(git log -1 --pretty=format:%s) TASKS=() + +echo "${green}βš™ PROJECT_PREFIXES:${reset}" +printf '%s\n' "${PROJECT_PREFIXES[@]}" +echo "${reset}" + echo "${blue}⚑ ️Last commit:${cyan}" echo $'\t'"πŸ“œ "$LAST_COMMIT echo "${reset}" @@ -45,20 +57,26 @@ then do echo $'\t'"πŸ“œ "${MERGES[$i]} done + for (( i=0 ; i<${#PROJECT_PREFIXES[*]} ; ++i )) + do + for task in $(echo ${MERGES[*]} | grep "${PROJECT_PREFIXES[$i]}[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) + do + TASKS+=($task) + done + done - for task in $(echo ${MERGES[*]} | grep "$project_prefix[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) - do - TASKS+=($task) - done else echo "${magenta}β˜‘οΈ Not a merge commit. Searching for tasks in current commit message...${cyan}" echo echo $'\t'"πŸ“œ "$LAST_COMMIT "${reset}" - for task in $(echo $LAST_COMMIT | grep "$project_prefix[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) - do - TASKS+=($task) - done + for (( i=0 ; i<${#PROJECT_PREFIXES[*]} ; ++i )) + do + for task in $(echo $LAST_COMMIT | grep "${PROJECT_PREFIXES[$i]}[0-9]{1,5}" -E -o || true | sort -u -r --version-sort) + do + TASKS+=($task) + done + done fi fi diff --git a/step.yml b/step.yml index b0b8888..b9f1f16 100644 --- a/step.yml +++ b/step.yml @@ -70,7 +70,7 @@ inputs: opts: title: "Jira project prefix" description: | - Project prefix to search for tasks. + Project prefix to search for tasks separatad with `|`. e.g. "PROJ-" is_expand: true From d28bfe8b709af8f5f0b051601085839717ff83a2 Mon Sep 17 00:00:00 2001 From: Artur Klamborowski Date: Thu, 15 Apr 2021 12:50:28 +0200 Subject: [PATCH 4/6] Replace quotes with single quote --- step.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/step.sh b/step.sh index b74d73e..e3bfa3e 100755 --- a/step.sh +++ b/step.sh @@ -92,7 +92,12 @@ echo "${blue}βœ‰οΈ Comment:${cyan}" echo "$jira_comment" echo "${reset}" -escaped_jira_comment=$(echo "$jira_comment" | perl -pe 's/\n/\\n/g' | sed 's/.\{2\}$//') +escaped_jira_comment=$(echo "$jira_comment" | perl -pe 's/\n/\\n/g' | sed 's/"/'\''/g' | sed 's/.\{2\}$//') + + +echo "${blue}βœ‰οΈ Escaped comment:${cyan}" +echo "$escaped_jira_comment" +echo "${reset}" create_comment_data() { From c3520cf8f0eca339bf498303fc8d4fe7795fb8d4 Mon Sep 17 00:00:00 2001 From: Mateusz_Druc Date: Wed, 4 Jan 2023 14:05:22 +0100 Subject: [PATCH 5/6] Add debug option to step --- step.sh | 5 +++++ step.yml | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/step.sh b/step.sh index e3bfa3e..fcb565c 100755 --- a/step.sh +++ b/step.sh @@ -2,6 +2,11 @@ set -e +# debug log +if [ "${show_debug_logs}" == "yes" ]; then + set -x +fi + red=$'\e[31m' green=$'\e[32m' blue=$'\e[34m' diff --git a/step.yml b/step.yml index b9f1f16..9eedcc3 100644 --- a/step.yml +++ b/step.yml @@ -105,3 +105,12 @@ inputs: opts: title: "Comment" description: "Comment that will be posted for each found Jira task" + - show_debug_logs: "no" + opts: + category: Debug + title: "Show debug logs?" + description: | + If debug=yes the step will print debug infos + value_options: + - "no" + - "yes" From 3ccb75f4bdbbb8137d47eaa36e1f7a354c443e7e Mon Sep 17 00:00:00 2001 From: Mateusz_Druc Date: Wed, 4 Jan 2023 16:25:59 +0100 Subject: [PATCH 6/6] Move --pretty=format:%B option before non-option arguments --- step.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/step.sh b/step.sh index fcb565c..db9d7eb 100755 --- a/step.sh +++ b/step.sh @@ -14,7 +14,7 @@ magenta=$'\e[35m' cyan=$'\e[36m' reset=$'\e[0m' -MERGES=$(git log $(git merge-base --octopus $(git log -1 --merges --pretty=format:%P))..$(git log -1 --merges --pretty=format:%H) --pretty=format:%B) +MERGES=$(git log --pretty=format:%B $(git merge-base --octopus $(git log -1 --merges --pretty=format:%P))..$(git log -1 --merges --pretty=format:%H)) SAVEDIFS=$IFS IFS=$'\n'