ff
This commit is contained in:
@@ -25,8 +25,9 @@ usage() {
|
||||
Usage: $(basename "$0") [--yes] [--dry-run] [--skip-tests] [--help]
|
||||
|
||||
Merge the local ${DEV_BRANCH} branch into ${MAIN_BRANCH}, remove agent-development files
|
||||
from ${MAIN_BRANCH}, create a release merge commit and tag, push to ${ORIGIN_REMOTE}/${MAIN_BRANCH},
|
||||
and switch back to ${DEV_BRANCH}.
|
||||
from ${MAIN_BRANCH}, auto-resolve merge conflicts limited to those cleanup paths,
|
||||
create a release merge commit and tag, push to ${ORIGIN_REMOTE}/${MAIN_BRANCH}, and
|
||||
switch back to ${DEV_BRANCH}.
|
||||
|
||||
Options:
|
||||
--yes Skip the interactive confirmation prompt.
|
||||
@@ -75,6 +76,65 @@ load_cleanup_paths() {
|
||||
fi
|
||||
}
|
||||
|
||||
path_is_cleanup_target() {
|
||||
local candidate_path="$1"
|
||||
local cleanup_path=""
|
||||
|
||||
for cleanup_path in "${AGENT_DEVELOPMENT_PATHS[@]}"; do
|
||||
case "${candidate_path}" in
|
||||
"${cleanup_path}"|"${cleanup_path}"/*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
auto_resolve_cleanup_conflicts() {
|
||||
local unmerged_paths=()
|
||||
local non_cleanup_conflicts=()
|
||||
local remaining_conflicts=()
|
||||
local conflicted_path=""
|
||||
|
||||
mapfile -t unmerged_paths < <(git diff --name-only --diff-filter=U)
|
||||
if [ "${#unmerged_paths[@]}" -eq 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
for conflicted_path in "${unmerged_paths[@]}"; do
|
||||
if ! path_is_cleanup_target "${conflicted_path}"; then
|
||||
non_cleanup_conflicts+=("${conflicted_path}")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${#non_cleanup_conflicts[@]}" -ne 0 ]; then
|
||||
printf 'Merge produced non-cleanup conflicts:\n' >&2
|
||||
for conflicted_path in "${non_cleanup_conflicts[@]}"; do
|
||||
printf ' - %s\n' "${conflicted_path}" >&2
|
||||
done
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf 'Auto-resolving merge conflicts for release-cleanup paths:\n'
|
||||
for conflicted_path in "${unmerged_paths[@]}"; do
|
||||
printf ' - %s\n' "${conflicted_path}"
|
||||
done
|
||||
|
||||
git rm -r --ignore-unmatch "${AGENT_DEVELOPMENT_PATHS[@]}" >/dev/null
|
||||
|
||||
mapfile -t remaining_conflicts < <(git diff --name-only --diff-filter=U)
|
||||
if [ "${#remaining_conflicts[@]}" -ne 0 ]; then
|
||||
printf 'Cleanup conflict auto-resolution left unresolved paths:\n' >&2
|
||||
for conflicted_path in "${remaining_conflicts[@]}"; do
|
||||
printf ' - %s\n' "${conflicted_path}" >&2
|
||||
done
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
require_repo_state() {
|
||||
if ! git rev-parse --show-toplevel >/dev/null 2>&1; then
|
||||
fail "This helper must be run inside a git repository."
|
||||
@@ -202,7 +262,7 @@ print_release_plan() {
|
||||
printf '3. Run ./tools/test.sh as the pre-release test gate.\n'
|
||||
fi
|
||||
printf '4. Switch to %s and merge %s with --no-ff --no-commit.\n' "${MAIN_BRANCH}" "${DEV_BRANCH}"
|
||||
printf '5. Remove release-cleanup paths from %s:\n' "${MAIN_BRANCH}"
|
||||
printf '5. Auto-resolve merge conflicts limited to release-cleanup paths and remove them from %s:\n' "${MAIN_BRANCH}"
|
||||
local cleanup_path=""
|
||||
for cleanup_path in "${AGENT_DEVELOPMENT_PATHS[@]}"; do
|
||||
printf ' - %s\n' "${cleanup_path}"
|
||||
@@ -252,9 +312,10 @@ RELEASE_COMMIT_MESSAGE="Release ${RELEASE_TAG}"
|
||||
require_release_tag_available "${RELEASE_VERSION}"
|
||||
|
||||
printf 'This will merge %s into %s, remove agent-development files on %s,\n' "${DEV_BRANCH}" "${MAIN_BRANCH}" "${MAIN_BRANCH}"
|
||||
printf 'run the pre-release gate%s, create %s, push to %s/%s, and switch back to %s.\n' \
|
||||
printf 'auto-resolve cleanup-path conflicts, run the pre-release gate%s, create %s,\n' \
|
||||
"$([ "${SKIP_TESTS}" -eq 1 ] && printf ' (skipped)' || printf '')" \
|
||||
"${RELEASE_TAG}" \
|
||||
"${RELEASE_TAG}"
|
||||
printf 'push to %s/%s, and switch back to %s.\n' \
|
||||
"${ORIGIN_REMOTE}" \
|
||||
"${MAIN_BRANCH}" \
|
||||
"${DEV_BRANCH}"
|
||||
@@ -288,8 +349,10 @@ CURRENT_BRANCH="${MAIN_BRANCH}"
|
||||
|
||||
printf 'Merging %s into %s...\n' "${DEV_BRANCH}" "${MAIN_BRANCH}"
|
||||
if ! git merge --no-ff --no-commit "${DEV_BRANCH}"; then
|
||||
if ! auto_resolve_cleanup_conflicts; then
|
||||
fail "Merge from '${DEV_BRANCH}' into '${MAIN_BRANCH}' failed."
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! git rev-parse -q --verify MERGE_HEAD >/dev/null 2>&1; then
|
||||
fail "'${MAIN_BRANCH}' is already up to date with '${DEV_BRANCH}'. Nothing to merge."
|
||||
|
||||
Reference in New Issue
Block a user