From 947dffca7e3792a54bbd2d4143153be3f923e6d5 Mon Sep 17 00:00:00 2001 From: Ansel Robateau Date: Wed, 11 Dec 2024 03:00:32 -0600 Subject: [PATCH 1/2] fix: find the correct git changes from log (CORE-1729) (#45) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 use merge-base to get changes from git log ✅ Closes: CORE-1729 * fix: 🐛 update workflow ✅ 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 ++++- .github/workflows/tag-tickets-with-release.yml | 3 ++- tooling/scripts/git_predict_next_version.sh | 10 ++++++---- 5 files changed, 24 insertions(+), 14 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/.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" 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 f243cf4243c29fdbf538e480772c54796d8700b4 Mon Sep 17 00:00:00 2001 From: Ansel Robateau Date: Wed, 11 Dec 2024 03:02:31 -0600 Subject: [PATCH 2/2] chore: update package version to v2.5.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d40e293..883629c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-actions", - "version": "2.5.1", + "version": "2.5.2", "description": "Used to store GitHub actions for use across the enterprise", "scripts": { "test": "./tooling/scripts/run_tests.sh",