From 9ce140c6f32bd3db8168beb9bbc44cb5015b7a8c Mon Sep 17 00:00:00 2001 From: Ansel Robateau Date: Wed, 11 Dec 2024 02:43:09 -0600 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20use=20merge-base=20to?= =?UTF-8?q?=20get=20changes=20from=20git=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: CORE-1729 --- .../predict-next-version/git_predict_next_version.sh | 10 ++++++---- .../tag-jira-release/git_predict_next_version.sh | 10 ++++++---- .github/actions/tag-jira-release/ticket_status.sh | 5 ++++- tooling/scripts/git_predict_next_version.sh | 10 ++++++---- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/actions/predict-next-version/git_predict_next_version.sh b/.github/actions/predict-next-version/git_predict_next_version.sh index 01b38c3..bfc17c1 100755 --- a/.github/actions/predict-next-version/git_predict_next_version.sh +++ b/.github/actions/predict-next-version/git_predict_next_version.sh @@ -30,15 +30,17 @@ git fetch function get_logs() { if [ "$GIT_LOGS" == "" ]; then - git log origin/main.. + git log $(git merge-base HEAD origin/main)..HEAD else echo "$GIT_LOGS" fi } -BREAKING_CHANGES="$(get_logs | grep "^\s*BREAKING CHANGE:")" -MINOR_CHANGES="$(get_logs | grep "^\s*feat[(:]")" -PATCH_CHANGES="$(get_logs | grep "^\s*fix[(:]")" +GIT_LOGS="$(get_logs)" + +BREAKING_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*BREAKING CHANGE:")" +MINOR_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*feat[(:]")" +PATCH_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*fix[(:]")" function print_changes() { local title=$1 diff --git a/.github/actions/tag-jira-release/git_predict_next_version.sh b/.github/actions/tag-jira-release/git_predict_next_version.sh index 024243a..96cc291 100755 --- a/.github/actions/tag-jira-release/git_predict_next_version.sh +++ b/.github/actions/tag-jira-release/git_predict_next_version.sh @@ -30,15 +30,17 @@ git fetch function get_logs() { if [ "$GIT_LOGS" == "" ]; then - git log ${TARGET_BRANCH}.. + git log $(git merge-base HEAD ${TARGET_BRANCH})..HEAD else echo "$GIT_LOGS" fi } -BREAKING_CHANGES="$(get_logs | grep "^\s*BREAKING CHANGE:")" -MINOR_CHANGES="$(get_logs | grep "^\s*feat[(:]")" -PATCH_CHANGES="$(get_logs | grep "^\s*fix[(:]")" +GIT_LOGS="$(get_logs)" + +BREAKING_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*BREAKING CHANGE:")" +MINOR_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*feat[(:]")" +PATCH_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*fix[(:]")" function print_changes() { local title=$1 diff --git a/.github/actions/tag-jira-release/ticket_status.sh b/.github/actions/tag-jira-release/ticket_status.sh index a0e3733..c90b275 100755 --- a/.github/actions/tag-jira-release/ticket_status.sh +++ b/.github/actions/tag-jira-release/ticket_status.sh @@ -12,13 +12,16 @@ CURRENT_BRANCH=$1 if [ "$CURRENT_BRANCH" == "" ]; then echo "Usage: [current_branch] [(optional) target_branch]" exit 1 +elif [ "$CURRENT_BRANCH" == "." ]; then + CURRENT_BRANCH=$(git branch --show-current) fi TARGET_BRANCH=main if [ "$2" != "" ]; then TARGET_BRANCH=$2 fi -HASHES=$(git log $TARGET_BRANCH..$CURRENT_BRANCH --pretty=format:'%H') +COMMON_BRANCH=$(git merge-base $TARGET_BRANCH $CURRENT_BRANCH) +HASHES=$(git log $COMMON_BRANCH..$CURRENT_BRANCH --pretty=format:'%H') if [ ! -d ~/temp ]; then mkdir ~/temp diff --git a/tooling/scripts/git_predict_next_version.sh b/tooling/scripts/git_predict_next_version.sh index 01b38c3..bfc17c1 100755 --- a/tooling/scripts/git_predict_next_version.sh +++ b/tooling/scripts/git_predict_next_version.sh @@ -30,15 +30,17 @@ git fetch function get_logs() { if [ "$GIT_LOGS" == "" ]; then - git log origin/main.. + git log $(git merge-base HEAD origin/main)..HEAD else echo "$GIT_LOGS" fi } -BREAKING_CHANGES="$(get_logs | grep "^\s*BREAKING CHANGE:")" -MINOR_CHANGES="$(get_logs | grep "^\s*feat[(:]")" -PATCH_CHANGES="$(get_logs | grep "^\s*fix[(:]")" +GIT_LOGS="$(get_logs)" + +BREAKING_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*BREAKING CHANGE:")" +MINOR_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*feat[(:]")" +PATCH_CHANGES="$(echo "$GIT_LOGS" | grep "^\s*fix[(:]")" function print_changes() { local title=$1 From df36c3d9b9948d609ee04261210e8cf24fc93e52 Mon Sep 17 00:00:00 2001 From: Ansel Robateau Date: Wed, 11 Dec 2024 02:52:36 -0600 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20update=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: CORE-1729 --- .github/workflows/tag-tickets-with-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tag-tickets-with-release.yml b/.github/workflows/tag-tickets-with-release.yml index 8cdc554..b84cfad 100644 --- a/.github/workflows/tag-tickets-with-release.yml +++ b/.github/workflows/tag-tickets-with-release.yml @@ -41,7 +41,8 @@ jobs: - name: create prompt id: create_prompt run: | - DIFF="$(git log --pretty=format:'%s' ${TARGET_BRANCH}..HEAD)" + COMMON_BRANCH=$(git merge-base HEAD ${TARGET_BRANCH}) + DIFF="$(git log --pretty=format:'%s' ${COMMON_BRANCH}..HEAD)" LLM_PROMPT_PREFIX="Create a fun release description in 100 characters or less in one line without identifiers for the following data: " LLM_PROMPT="$LLM_PROMPT_PREFIX$DIFF"