Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -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-"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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)" {
Expand Down