Added to .maintain-custom-release.sh an explicit UPSTREAM_RELEASE_TARGET_REF setting so the upstream import can stop at a chosen tag such as v1.26.0 instead of always importing to the current head of upstream/release/v1.26, and I also made rollback clean up the original backup/maint-* branch and fetched upstream/* refs so a canceled bootstrap leaves the branch graph closer to its pre-run state.
This commit is contained in:
@@ -778,3 +778,4 @@ Project Change ID[date-time] - application-version - Type - Summary:
|
||||
- 5 - I added a legacy restore-point fallback so older restore points that predate the script-managed ref snapshot files now explicitly remove current `upstream/*`, maintenance-branch, `backup/maint-*`, state-file, and snapshot artifacts instead of leaving them behind after restore.
|
||||
- 6 - I fixed the script-managed ref discovery itself so restore cleanup now matches `refs/remotes/upstream/...` and `backup/maint-...` by prefix instead of a non-matching glob pattern, which was the reason `upstream/release/v1.26` could still remain after a restore.
|
||||
- 7 - I tightened the manual restore-point management so `list-restore-points` now shows only valid restore points that still have their Git Graph marker branch, while `delete-restore-point` can still remove orphaned restore-point directories even after their associated backup branch has already been deleted manually.
|
||||
- 8 - I added an explicit `UPSTREAM_RELEASE_TARGET_REF` setting so the upstream import can stop at a chosen tag such as `v1.26.0` instead of always importing to the current head of `upstream/release/v1.26`, and I also made `rollback` clean up the original `backup/maint-*` branch and fetched `upstream/*` refs so a canceled bootstrap leaves the branch graph closer to its pre-run state.
|
||||
|
||||
@@ -19,6 +19,7 @@ set -euo pipefail
|
||||
|
||||
BASE_TAG="${BASE_TAG:-v1.26.0-rc0}"
|
||||
UPSTREAM_RELEASE_BRANCH="${UPSTREAM_RELEASE_BRANCH:-release/v1.26}"
|
||||
UPSTREAM_RELEASE_TARGET_REF="${UPSTREAM_RELEASE_TARGET_REF:-}"
|
||||
MAINTENANCE_BRANCH="${MAINTENANCE_BRANCH:-release/v1.26-custom}"
|
||||
CUSTOM_SOURCE_BRANCH="${CUSTOM_SOURCE_BRANCH:-main}"
|
||||
UPSTREAM_COMPARE_BRANCH="${UPSTREAM_COMPARE_BRANCH:-main}"
|
||||
@@ -44,6 +45,7 @@ STATE_REMOTE_NAME=""
|
||||
STATE_REMOTE_URL=""
|
||||
STATE_BASE_TAG=""
|
||||
STATE_UPSTREAM_RELEASE_BRANCH=""
|
||||
STATE_UPSTREAM_RELEASE_TARGET_REF=""
|
||||
STATE_UPSTREAM_COMPARE_BRANCH=""
|
||||
STATE_CUSTOM_SOURCE_BRANCH=""
|
||||
STATE_MAINTENANCE_BRANCH=""
|
||||
@@ -74,6 +76,7 @@ Usage: $(basename "$0") [command]
|
||||
Environment defaults:
|
||||
BASE_TAG=$BASE_TAG
|
||||
UPSTREAM_RELEASE_BRANCH=$UPSTREAM_RELEASE_BRANCH
|
||||
UPSTREAM_RELEASE_TARGET_REF=${UPSTREAM_RELEASE_TARGET_REF:-<branch-head>}
|
||||
MAINTENANCE_BRANCH=$MAINTENANCE_BRANCH
|
||||
CUSTOM_SOURCE_BRANCH=$CUSTOM_SOURCE_BRANCH
|
||||
UPSTREAM_COMPARE_BRANCH=$UPSTREAM_COMPARE_BRANCH
|
||||
@@ -99,7 +102,7 @@ Available commands:
|
||||
bootstrap
|
||||
Create or switch to the maintenance branch from BASE_TAG without importing any commits.
|
||||
sync-upstream
|
||||
Import only the missing commits from upstream/\$UPSTREAM_RELEASE_BRANCH.
|
||||
Import only the missing commits from the configured upstream release target ref, or from upstream/\$UPSTREAM_RELEASE_BRANCH when no target ref is set.
|
||||
sync-custom
|
||||
Import only your custom commits from \$CUSTOM_SOURCE_BRANCH.
|
||||
sync-all
|
||||
@@ -130,6 +133,7 @@ Recommended order:
|
||||
- only upstream first: ./.maintain-custom-release.sh sync-upstream
|
||||
- only your custom commits: ./.maintain-custom-release.sh sync-custom
|
||||
- or both in one step: ./.maintain-custom-release.sh sync-all
|
||||
- for a fixed upstream release such as v1.26.0, set UPSTREAM_RELEASE_TARGET_REF first
|
||||
6. Later patch releases on the same series:
|
||||
- keep the same upstream minor release branch, for example release/v1.26
|
||||
- run the sync step you want, usually: ./.maintain-custom-release.sh sync-all
|
||||
@@ -156,6 +160,20 @@ prompt_with_default() {
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_with_default_allow_clear() {
|
||||
local prompt="$1" current_value="$2" reply=""
|
||||
|
||||
printf '%s [%s]: ' "$prompt" "$current_value" >&2
|
||||
read -r reply
|
||||
if [ "$reply" = "-" ]; then
|
||||
printf '\n'
|
||||
elif [ -n "$reply" ]; then
|
||||
printf '%s\n' "$reply"
|
||||
else
|
||||
printf '%s\n' "$current_value"
|
||||
fi
|
||||
}
|
||||
|
||||
normalize_upstream_release_branch() {
|
||||
local fallback_branch=""
|
||||
|
||||
@@ -200,6 +218,7 @@ write_state() {
|
||||
printf 'STATE_REMOTE_URL=%q\n' "$STATE_REMOTE_URL"
|
||||
printf 'STATE_BASE_TAG=%q\n' "$STATE_BASE_TAG"
|
||||
printf 'STATE_UPSTREAM_RELEASE_BRANCH=%q\n' "$STATE_UPSTREAM_RELEASE_BRANCH"
|
||||
printf 'STATE_UPSTREAM_RELEASE_TARGET_REF=%q\n' "$STATE_UPSTREAM_RELEASE_TARGET_REF"
|
||||
printf 'STATE_UPSTREAM_COMPARE_BRANCH=%q\n' "$STATE_UPSTREAM_COMPARE_BRANCH"
|
||||
printf 'STATE_CUSTOM_SOURCE_BRANCH=%q\n' "$STATE_CUSTOM_SOURCE_BRANCH"
|
||||
printf 'STATE_MAINTENANCE_BRANCH=%q\n' "$STATE_MAINTENANCE_BRANCH"
|
||||
@@ -219,6 +238,14 @@ load_state() {
|
||||
[ -f "$STATE_FILE" ] || return 1
|
||||
# shellcheck disable=SC1090
|
||||
. "$STATE_FILE"
|
||||
[ -n "${STATE_BASE_TAG:-}" ] && BASE_TAG="$STATE_BASE_TAG"
|
||||
[ -n "${STATE_UPSTREAM_RELEASE_BRANCH:-}" ] && UPSTREAM_RELEASE_BRANCH="$STATE_UPSTREAM_RELEASE_BRANCH"
|
||||
if [ -n "${STATE_UPSTREAM_RELEASE_TARGET_REF:-}" ] || [ "${STATE_UPSTREAM_RELEASE_TARGET_REF+x}" = "x" ]; then
|
||||
UPSTREAM_RELEASE_TARGET_REF="${STATE_UPSTREAM_RELEASE_TARGET_REF:-}"
|
||||
fi
|
||||
[ -n "${STATE_UPSTREAM_COMPARE_BRANCH:-}" ] && UPSTREAM_COMPARE_BRANCH="$STATE_UPSTREAM_COMPARE_BRANCH"
|
||||
[ -n "${STATE_CUSTOM_SOURCE_BRANCH:-}" ] && CUSTOM_SOURCE_BRANCH="$STATE_CUSTOM_SOURCE_BRANCH"
|
||||
[ -n "${STATE_MAINTENANCE_BRANCH:-}" ] && MAINTENANCE_BRANCH="$STATE_MAINTENANCE_BRANCH"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -664,6 +691,16 @@ restore_fetch_ref_states() {
|
||||
done <<< "${STATE_FETCH_REF_STATES}"
|
||||
}
|
||||
|
||||
resolve_upstream_release_import_ref() {
|
||||
if [ -n "$UPSTREAM_RELEASE_TARGET_REF" ]; then
|
||||
git rev-parse --verify "$UPSTREAM_RELEASE_TARGET_REF" >/dev/null 2>&1 || die "Configured upstream release target ref '$UPSTREAM_RELEASE_TARGET_REF' does not exist locally."
|
||||
printf '%s\n' "$UPSTREAM_RELEASE_TARGET_REF"
|
||||
return
|
||||
fi
|
||||
|
||||
printf '%s/%s\n' "$REMOTE_NAME" "$UPSTREAM_RELEASE_BRANCH"
|
||||
}
|
||||
|
||||
maintenance_branch_exists() {
|
||||
git show-ref --verify --quiet "refs/heads/$MAINTENANCE_BRANCH"
|
||||
}
|
||||
@@ -771,6 +808,7 @@ update_state() {
|
||||
STATE_REMOTE_URL="$REMOTE_URL"
|
||||
STATE_BASE_TAG="$BASE_TAG"
|
||||
STATE_UPSTREAM_RELEASE_BRANCH="$UPSTREAM_RELEASE_BRANCH"
|
||||
STATE_UPSTREAM_RELEASE_TARGET_REF="$UPSTREAM_RELEASE_TARGET_REF"
|
||||
STATE_UPSTREAM_COMPARE_BRANCH="$UPSTREAM_COMPARE_BRANCH"
|
||||
STATE_CUSTOM_SOURCE_BRANCH="$CUSTOM_SOURCE_BRANCH"
|
||||
STATE_MAINTENANCE_BRANCH="$MAINTENANCE_BRANCH"
|
||||
@@ -839,9 +877,11 @@ restore_stash() {
|
||||
}
|
||||
|
||||
ordered_upstream_release_commits_for_ref() {
|
||||
local target_ref="$1" available_commit_shas="" commit
|
||||
local target_ref="$1" source_ref="" available_commit_shas="" commit
|
||||
|
||||
available_commit_shas="$(git cherry -v "$target_ref" "$REMOTE_NAME/$UPSTREAM_RELEASE_BRANCH" | awk '$1=="+"{print $2}')"
|
||||
source_ref="$(resolve_upstream_release_import_ref)"
|
||||
|
||||
available_commit_shas="$(git cherry -v "$target_ref" "$source_ref" | awk '$1=="+"{print $2}')"
|
||||
[ -n "$available_commit_shas" ] || return 0
|
||||
|
||||
while IFS= read -r commit; do
|
||||
@@ -849,7 +889,7 @@ ordered_upstream_release_commits_for_ref() {
|
||||
if printf '%s\n' "$available_commit_shas" | grep -Fxq "$commit"; then
|
||||
printf '%s\n' "$commit"
|
||||
fi
|
||||
done < <(git rev-list --reverse "${target_ref}..$REMOTE_NAME/$UPSTREAM_RELEASE_BRANCH")
|
||||
done < <(git rev-list --reverse "${target_ref}..$source_ref")
|
||||
}
|
||||
|
||||
ordered_custom_commits_not_in_ref() {
|
||||
@@ -889,6 +929,7 @@ run_configure() {
|
||||
say "Interactive configuration"
|
||||
BASE_TAG="$(prompt_with_default "Base tag" "$BASE_TAG")"
|
||||
UPSTREAM_RELEASE_BRANCH="$(prompt_with_default "Upstream release branch (for example release/v1.26)" "$UPSTREAM_RELEASE_BRANCH")"
|
||||
UPSTREAM_RELEASE_TARGET_REF="$(prompt_with_default_allow_clear "Upstream release target ref (example v1.26.0, use - to clear)" "$UPSTREAM_RELEASE_TARGET_REF")"
|
||||
MAINTENANCE_BRANCH="$(prompt_with_default "Custom maintenance branch" "$MAINTENANCE_BRANCH")"
|
||||
CUSTOM_SOURCE_BRANCH="$(prompt_with_default "Custom source branch" "$CUSTOM_SOURCE_BRANCH")"
|
||||
UPSTREAM_COMPARE_BRANCH="$(prompt_with_default "Upstream compare branch" "$UPSTREAM_COMPARE_BRANCH")"
|
||||
@@ -1013,6 +1054,7 @@ run_status() {
|
||||
say "Maintenance branch: $MAINTENANCE_BRANCH"
|
||||
say "Base tag: $BASE_TAG"
|
||||
say "Upstream release branch: $REMOTE_NAME/$UPSTREAM_RELEASE_BRANCH"
|
||||
say "Upstream release target ref: ${UPSTREAM_RELEASE_TARGET_REF:-$REMOTE_NAME/$UPSTREAM_RELEASE_BRANCH}"
|
||||
say "Custom source branch: $CUSTOM_SOURCE_BRANCH"
|
||||
say "Upstream compare branch: $REMOTE_NAME/$UPSTREAM_COMPARE_BRANCH"
|
||||
say "Custom tag suffix: $CUSTOM_TAG_SUFFIX"
|
||||
@@ -1227,6 +1269,7 @@ run_restore_saved_stash() {
|
||||
run_rollback() {
|
||||
local explicit_target="${1:-}" reset_target="" reset_snapshot=""
|
||||
local original_restore_stash_hash="" original_restore_start_head=""
|
||||
local original_action_backup_branch="" original_action_snapshot=""
|
||||
local rollback_safety_snapshot="" rollback_safety_backup="" rollback_safety_start_head=""
|
||||
local preserve_stash_hash=""
|
||||
local restore_branch_after="" created_branch_name="" remove_created_branch="0"
|
||||
@@ -1276,6 +1319,8 @@ run_rollback() {
|
||||
|
||||
original_restore_stash_hash="${STATE_STASH_HASH:-}"
|
||||
original_restore_start_head="${STATE_START_HEAD:-}"
|
||||
original_action_backup_branch="${STATE_BACKUP_BRANCH:-}"
|
||||
original_action_snapshot="${STATE_SNAPSHOT_PATH:-}"
|
||||
restore_branch_after="${STATE_ENTRY_BRANCH:-}"
|
||||
created_branch_name="${STATE_BRANCH:-$MAINTENANCE_BRANCH}"
|
||||
remove_created_branch="${STATE_CREATED_MAINTENANCE_BRANCH:-0}"
|
||||
@@ -1347,6 +1392,7 @@ run_rollback() {
|
||||
STATE_REMOTE_URL="$REMOTE_URL"
|
||||
STATE_BASE_TAG="$BASE_TAG"
|
||||
STATE_UPSTREAM_RELEASE_BRANCH="$UPSTREAM_RELEASE_BRANCH"
|
||||
STATE_UPSTREAM_RELEASE_TARGET_REF="$UPSTREAM_RELEASE_TARGET_REF"
|
||||
STATE_UPSTREAM_COMPARE_BRANCH="$UPSTREAM_COMPARE_BRANCH"
|
||||
STATE_CUSTOM_SOURCE_BRANCH="$CUSTOM_SOURCE_BRANCH"
|
||||
STATE_MAINTENANCE_BRANCH="$MAINTENANCE_BRANCH"
|
||||
@@ -1362,6 +1408,9 @@ run_rollback() {
|
||||
say "Safety snapshot of the pre-rollback state kept at: $rollback_safety_snapshot"
|
||||
say "Safety stash of the pre-rollback local changes kept at: $preserve_stash_hash"
|
||||
else
|
||||
if [ -z "$explicit_target" ]; then
|
||||
cleanup_temporary_restore_artifacts "$original_action_backup_branch" "$original_action_snapshot"
|
||||
fi
|
||||
cleanup_temporary_restore_artifacts "$rollback_safety_backup" "$rollback_safety_snapshot"
|
||||
rm -f "$STATE_FILE"
|
||||
say "Temporary rollback safety artifacts were cleaned up."
|
||||
@@ -1430,6 +1479,7 @@ run_restore_snapshot() {
|
||||
STATE_REMOTE_URL="$REMOTE_URL"
|
||||
STATE_BASE_TAG="$BASE_TAG"
|
||||
STATE_UPSTREAM_RELEASE_BRANCH="$UPSTREAM_RELEASE_BRANCH"
|
||||
STATE_UPSTREAM_RELEASE_TARGET_REF="$UPSTREAM_RELEASE_TARGET_REF"
|
||||
STATE_UPSTREAM_COMPARE_BRANCH="$UPSTREAM_COMPARE_BRANCH"
|
||||
STATE_CUSTOM_SOURCE_BRANCH="$CUSTOM_SOURCE_BRANCH"
|
||||
STATE_MAINTENANCE_BRANCH="$MAINTENANCE_BRANCH"
|
||||
@@ -1514,6 +1564,7 @@ run_restore_restore_point() {
|
||||
STATE_REMOTE_URL="$REMOTE_URL"
|
||||
STATE_BASE_TAG="$BASE_TAG"
|
||||
STATE_UPSTREAM_RELEASE_BRANCH="$UPSTREAM_RELEASE_BRANCH"
|
||||
STATE_UPSTREAM_RELEASE_TARGET_REF="$UPSTREAM_RELEASE_TARGET_REF"
|
||||
STATE_UPSTREAM_COMPARE_BRANCH="$UPSTREAM_COMPARE_BRANCH"
|
||||
STATE_CUSTOM_SOURCE_BRANCH="$CUSTOM_SOURCE_BRANCH"
|
||||
STATE_MAINTENANCE_BRANCH="$MAINTENANCE_BRANCH"
|
||||
|
||||
Reference in New Issue
Block a user