Add --force flag to reverse sync
Bypasses the PR step and force-pushes the subrepo's state directly onto the monorepo branch. Also skips the skip-dirty guard. Only valid with --reverse. Returns status "forced". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -88,6 +88,7 @@ Global flags:
|
||||
Sync flags:
|
||||
--forward Forward only (mono → subrepo)
|
||||
--reverse Reverse only (subrepo → mono)
|
||||
--force Force-push subrepo state to mono branch (--reverse only, skips PR)
|
||||
--target NAME Filter to target(s) — comma-separated for multiple (env: JOSH_SYNC_TARGET)
|
||||
--branch BRANCH Filter to one branch
|
||||
|
||||
@@ -108,6 +109,7 @@ cmd_sync() {
|
||||
local filter_target="${JOSH_SYNC_TARGET:-}"
|
||||
local filter_branch=""
|
||||
local config_file=".josh-sync.yml"
|
||||
local force_flag=false
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -117,10 +119,18 @@ cmd_sync() {
|
||||
--branch) filter_branch="$2"; shift 2 ;;
|
||||
--config) config_file="$2"; shift 2 ;;
|
||||
--debug) export JOSH_SYNC_DEBUG=1; shift ;;
|
||||
--force) force_flag=true; shift ;;
|
||||
*) die "Unknown flag: $1" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$force_flag" = true ] && [ "$direction" != "reverse" ]; then
|
||||
die "--force requires --reverse"
|
||||
fi
|
||||
if [ "$force_flag" = true ]; then
|
||||
export SYNC_REVERSE_FORCE=1
|
||||
fi
|
||||
|
||||
parse_config "$config_file"
|
||||
|
||||
# Forward sync
|
||||
@@ -263,6 +273,9 @@ _sync_direction() {
|
||||
log "WARN" "Trees differ but no human commits — skipping state update (will retry)"
|
||||
continue
|
||||
fi
|
||||
if [ "$result" = "forced" ]; then
|
||||
log "WARN" "Target ${target_name}, branch ${branch}: force-pushed subrepo directly to mono — DESTRUCTIVE"
|
||||
fi
|
||||
|
||||
# Update state (only on success)
|
||||
local new_state
|
||||
|
||||
Reference in New Issue
Block a user