This commit is contained in:
2026-05-26 10:38:20 +03:00
parent b28662d3b4
commit f2e39be5e1
10 changed files with 588 additions and 17 deletions

View File

@@ -8,6 +8,7 @@
# sync Run forward and/or reverse sync
# preflight Validate config, connectivity, auth
# import <target> Initial import: pull subrepo into monorepo
# adopt <target> Adopt existing subrepo history without rewriting it
# reset <target> Reset subrepo to josh-filtered view
# onboard <target> Import existing subrepo into monorepo (interactive)
# migrate-pr <target> [PR#...] [--all] Move PRs from archived to new subrepo
@@ -41,6 +42,8 @@ source "${JOSH_LIB_DIR}/auth.sh"
source "${JOSH_LIB_DIR}/state.sh"
# shellcheck source=../lib/sync.sh
source "${JOSH_LIB_DIR}/sync.sh"
# shellcheck source=../lib/adopt.sh
source "${JOSH_LIB_DIR}/adopt.sh"
# shellcheck source=../lib/onboard.sh
source "${JOSH_LIB_DIR}/onboard.sh"
@@ -72,6 +75,7 @@ Commands:
sync Run forward and/or reverse sync
preflight Validate config, connectivity, auth, workflow coverage
import <target> Initial import: pull existing subrepo into monorepo (creates PR)
adopt <target> Adopt existing subrepo history without rewriting it
reset <target> Reset subrepo to josh-filtered view (after merging import PR)
onboard <target> Import existing subrepo into monorepo (interactive, resumable)
migrate-pr <target> [PR#...] [--all] Move PRs from archived to new subrepo
@@ -530,6 +534,42 @@ cmd_import() {
done
}
# ─── Adopt Command ─────────────────────────────────────────────────
cmd_adopt() {
local config_file=".josh-sync.yml"
local target_name=""
local restart=false
while [ $# -gt 0 ]; do
case "$1" in
--config) config_file="$2"; shift 2 ;;
--debug) export JOSH_SYNC_DEBUG=1; shift ;;
--restart) restart=true; shift ;;
-*) die "Unknown flag: $1" ;;
*) target_name="$1"; shift ;;
esac
done
if [ -z "$target_name" ]; then
echo "Usage: josh-sync adopt <target> [--restart]" >&2
parse_config "$config_file"
echo "Available targets:" >&2
echo "$JOSH_SYNC_TARGETS" | jq -r '.[].name' | sed 's/^/ /' >&2
exit 1
fi
parse_config "$config_file"
local target_json
target_json=$(echo "$JOSH_SYNC_TARGETS" | jq -c --arg n "$target_name" '.[] | select(.name == $n)')
[ -n "$target_json" ] || die "Target '${target_name}' not found in config"
log "INFO" "══════ Adopt target: ${target_name} ══════"
load_target "$target_json"
adopt_flow "$target_json" "$restart"
}
# ─── Reset Command ─────────────────────────────────────────────────
cmd_reset() {
@@ -886,6 +926,7 @@ main() {
sync) cmd_sync "$@" ;;
preflight) cmd_preflight "$@" ;;
import) cmd_import "$@" ;;
adopt) cmd_adopt "$@" ;;
reset) cmd_reset "$@" ;;
onboard) cmd_onboard "$@" ;;
migrate-pr) cmd_migrate_pr "$@" ;;