diff --git a/.github/actions/universal-detect-changes-and-generate-changelog/cache-keys.sh b/.github/actions/universal-detect-changes-and-generate-changelog/cache-keys.sh index f92be37..0df3979 100755 --- a/.github/actions/universal-detect-changes-and-generate-changelog/cache-keys.sh +++ b/.github/actions/universal-detect-changes-and-generate-changelog/cache-keys.sh @@ -1,6 +1,9 @@ #!/bin/bash set -e +# Store original prefix for debug output +ORIGINAL_CACHE_KEY_PREFIX="$CACHE_KEY_PREFIX" + # Generate cache key prefix based on input if [ -n "$CACHE_KEY_PREFIX" ]; then CACHE_KEY_PREFIX="${CACHE_KEY_PREFIX}-latest_builded_commit-" @@ -9,7 +12,8 @@ else fi # Debug output if enabled -if [ "$DEBUG" == "true" ]; then +if [ "$DEBUG" == "true" ]; then + echo "[DEBUG] CACHE_KEY_PREFIX='$ORIGINAL_CACHE_KEY_PREFIX'" echo "[DEBUG] CACHE_KEY_PREFIX='$CACHE_KEY_PREFIX'" echo "[DEBUG] CALCULATED_CACHE_KEY='$CACHE_KEY_PREFIX$GITHUB_SHA'" fi diff --git a/.github/actions/universal-detect-changes-and-generate-changelog/generate-changelog.sh b/.github/actions/universal-detect-changes-and-generate-changelog/generate-changelog.sh index 7ade702..4e70baf 100755 --- a/.github/actions/universal-detect-changes-and-generate-changelog/generate-changelog.sh +++ b/.github/actions/universal-detect-changes-and-generate-changelog/generate-changelog.sh @@ -38,20 +38,20 @@ get_branch_names() { if [ "$from_commit" == "$to_commit" ]; then git log --merges --first-parent --pretty=format:"%s" HEAD~1..HEAD | \ sed -e "s/^Merge branch '//" -e "s/^Merge pull request .* from //" -e "s/' into.*$//" -e "s/ into.*$//" | \ - grep -v '^$' 2>&1 - return $? + grep -v '^$' 2>&1 || true + return 0 else git log --merges --first-parent --pretty=format:"%s" "${from_commit}..${to_commit}" | \ sed -e "s/^Merge branch '//" -e "s/^Merge pull request .* from //" -e "s/' into.*$//" -e "s/ into.*$//" | \ - grep -v '^$' 2>&1 - return $? + grep -v '^$' 2>&1 || true + return 0 fi } # Check if string is empty (after removing whitespace) is_empty() { local text="$1" - [ -z "$(echo "$text" | tr -d '\n\r')" ] + [ -z "$(echo "$text" | tr -d '\n\r \t')" ] } # Format changelog text @@ -141,8 +141,8 @@ main() { if [ $git_exit_code -eq 0 ]; then raw_branch_names=$(git log --merges --first-parent --pretty=format:"%s" HEAD~1..HEAD 2>&1 | \ sed -e "s/^Merge branch '//" -e "s/^Merge pull request .* from //" -e "s/' into.*$//" -e "s/ into.*$//" | \ - grep -v '^$' 2>&1) - git_exit_code=$? + grep -v '^$' 2>&1 || true) + git_exit_code=0 else raw_branch_names="" fi @@ -154,8 +154,8 @@ main() { if [ $git_exit_code -eq 0 ]; then raw_branch_names=$(git log --merges --first-parent --pretty=format:"%s" "${FROM_COMMIT}..${TO_COMMIT}" 2>&1 | \ sed -e "s/^Merge branch '//" -e "s/^Merge pull request .* from //" -e "s/' into.*$//" -e "s/ into.*$//" | \ - grep -v '^$' 2>&1) - git_exit_code=$? + grep -v '^$' 2>&1 || true) + git_exit_code=0 else raw_branch_names="" fi diff --git a/.github/actions/universal-detect-changes-and-generate-changelog/test/test_generate-changelog.bats b/.github/actions/universal-detect-changes-and-generate-changelog/test/test_generate-changelog.bats index cff1d23..3bacca1 100755 --- a/.github/actions/universal-detect-changes-and-generate-changelog/test/test_generate-changelog.bats +++ b/.github/actions/universal-detect-changes-and-generate-changelog/test/test_generate-changelog.bats @@ -191,7 +191,7 @@ load 'test_helper' run "$BATS_TEST_DIRNAME/../generate-changelog.sh" [ "$status" -eq 0 ] - [ "$(grep '^changelog_string=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "Message with newlines, and special chars: @#$%, and quotes: \"test\"" ] + [ "$(grep '^changelog_string=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "Message with newlines, and special chars: @#$%25, and quotes: \"test\"" ] } @test "generate-changelog: handles empty branch names" { @@ -355,7 +355,7 @@ load 'test_helper' [ "$status" -eq 0 ] # Quotes should be preserved and outputs remain a single line key=value (no YAML/shell breakage) [ "$(grep '^changelog_string=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "Fix: handle \"quoted\" values in output, Ensure it's safe when there's a 'single quote' too" ] - [ "$(grep '^merged_branches=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "feature-quoted-\"name\", feature-another'quoted'branch" ] + [ "$(grep '^merged_branches=' "$GITHUB_OUTPUT" | cut -d= -f2)" = "feature-another'quoted'branch, feature-quoted-\"name\"" ] } @test "generate-changelog: handles raw double quotes via here-doc (no escaping in source)" {