Updated on 2026-08-14

This commit is contained in:
Tangem 2025-01-30 17:30:26 +02:00
parent 1133c53251
commit d9dc6ce158

View file

@ -16,16 +16,17 @@ latest_merge_base=""
# Source refs to find branches from
local_refs="refs/heads/releases/*" # For debug and development
remote_refs=$(git for-each-ref --format="%(refname:short)" refs/remotes/origin/ | grep -E "origin/[a-zA-Z0-9._-]+_pre_release$")
remote_refs=$(git for-each-ref --sort=-committerdate --format="%(refname:short)" refs/remotes/origin/ | grep -E "origin/[a-zA-Z0-9._-]+_pre_release$")
# Iterate over all remote release branches sorted by commit date (most recent first)
for branch in $remote_refs; do
# Find the common ancestor (merge base) between the base branch and the current branch
merge_base=$(git merge-base "$base_branch" "$branch")
echo "Merge base for branches '$branch' and '$base_branch' is '$merge_base'"
if [ -z "$latest_merge_base" ] || git rev-list "$merge_base..$base_branch" | grep -q .; then
echo "Update"
# Update the latest branch and merge base if the current merge base is a descendant of the latest merge base
if [ -z "$latest_merge_base" ] || git merge-base --is-ancestor "$latest_merge_base" "$merge_base"; then
latest_branch="$branch"
latest_merge_base="$merge_base"
fi
@ -45,4 +46,4 @@ fi
latest_branch="${latest_branch#origin/}"
echo "$latest_branch" > "find-latest-pre-release-branch.output"
echo "Latest release branch created directly from '$base_branch' or its ancestor: '$latest_branch'"
echo "Latest 'pre_release' branch created from '$base_branch' or its ancestor: '$latest_branch'"