Fix onboard import cloning from empty new repo instead of archived repo
initial_import() now accepts an optional clone URL override parameter. onboard_flow() passes the archived repo URL so content is cloned from the right source. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,17 @@ onboard_flow() {
|
|||||||
local import_prs
|
local import_prs
|
||||||
import_prs=$(echo "$onboard_state" | jq -r '.import_prs // {}')
|
import_prs=$(echo "$onboard_state" | jq -r '.import_prs // {}')
|
||||||
|
|
||||||
|
# Build the archived repo clone URL for initial_import().
|
||||||
|
# The content lives in the archived repo — the new repo at SUBREPO_URL is empty.
|
||||||
|
local archived_url archived_clone_url
|
||||||
|
archived_url=$(echo "$onboard_state" | jq -r '.archived_url')
|
||||||
|
if [ "${SUBREPO_AUTH:-https}" = "ssh" ]; then
|
||||||
|
archived_clone_url="$archived_url"
|
||||||
|
else
|
||||||
|
# shellcheck disable=SC2001
|
||||||
|
archived_clone_url=$(echo "$archived_url" | sed "s|https://|https://${BOT_USER}:${SUBREPO_TOKEN}@|")
|
||||||
|
fi
|
||||||
|
|
||||||
for branch in $branches; do
|
for branch in $branches; do
|
||||||
local mapped
|
local mapped
|
||||||
mapped=$(echo "$target_json" | jq -r --arg b "$branch" '.branches[$b] // empty')
|
mapped=$(echo "$target_json" | jq -r --arg b "$branch" '.branches[$b] // empty')
|
||||||
@@ -185,7 +196,7 @@ onboard_flow() {
|
|||||||
|
|
||||||
log "INFO" "Importing branch: ${branch} (subrepo: ${mapped})"
|
log "INFO" "Importing branch: ${branch} (subrepo: ${mapped})"
|
||||||
local result
|
local result
|
||||||
result=$(initial_import)
|
result=$(initial_import "$archived_clone_url")
|
||||||
log "INFO" "Import result for ${branch}: ${result}"
|
log "INFO" "Import result for ${branch}: ${result}"
|
||||||
|
|
||||||
if [ "$result" = "pr-created" ]; then
|
if [ "$result" = "pr-created" ]; then
|
||||||
|
|||||||
@@ -200,9 +200,13 @@ reverse_sync() {
|
|||||||
#
|
#
|
||||||
# Used when a subrepo already has content and you're adding it to the
|
# Used when a subrepo already has content and you're adding it to the
|
||||||
# monorepo for the first time. Creates a PR.
|
# monorepo for the first time. Creates a PR.
|
||||||
|
# Usage: initial_import [clone_url_override]
|
||||||
|
# clone_url_override — if set, clone from this URL instead of subrepo_auth_url()
|
||||||
|
# (used by onboard to clone from the archived repo)
|
||||||
# Returns: skip | pr-created
|
# Returns: skip | pr-created
|
||||||
|
|
||||||
initial_import() {
|
initial_import() {
|
||||||
|
local clone_url="${1:-$(subrepo_auth_url)}"
|
||||||
local mono_branch="$SYNC_BRANCH_MONO"
|
local mono_branch="$SYNC_BRANCH_MONO"
|
||||||
local subrepo_branch="$SYNC_BRANCH_SUBREPO"
|
local subrepo_branch="$SYNC_BRANCH_SUBREPO"
|
||||||
local subfolder
|
local subfolder
|
||||||
@@ -225,8 +229,8 @@ initial_import() {
|
|||||||
--branch "$mono_branch" --single-branch \
|
--branch "$mono_branch" --single-branch \
|
||||||
"${work_dir}/monorepo" || die "Failed to clone monorepo"
|
"${work_dir}/monorepo" || die "Failed to clone monorepo"
|
||||||
|
|
||||||
# 2. Clone subrepo
|
# 2. Clone subrepo (or archived repo when clone_url is overridden)
|
||||||
git clone "$(subrepo_auth_url)" \
|
git clone "$clone_url" \
|
||||||
--branch "$subrepo_branch" --single-branch \
|
--branch "$subrepo_branch" --single-branch \
|
||||||
"${work_dir}/subrepo" || die "Failed to clone subrepo"
|
"${work_dir}/subrepo" || die "Failed to clone subrepo"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user