fix gitimport: create Sapling bookmark after import, fix sl clone to pull correct branch

Anton Kaminsky28d ago6d5220729d96parent 416062b
2 files changed+19-1
api/src/routes/repos.ts
@@ -853,6 +853,20 @@
853853 send("log", { step: "import", line });
854854 });
855855
856 // Create Sapling-style bookmark (gitimport creates "heads/main", Sapling needs "main")
857 send("progress", { step: "import", message: "Creating bookmarks..." });
858
859 await runDocker([
860 "run", "--rm",
861 "-v", "/data/grove:/data/grove",
862 "--entrypoint", "sh",
863 "grove/mononoke:latest",
864 "-c",
865 `CSID=$(admin --config-path ${MONONOKE_CONFIG_PATH} --local-configerator-path ${DATA_DIR}/configerator --cache-mode disabled --just-knobs-config-path ${DATA_DIR}/justknobs.json bookmarks --repo-name ${repoName} list 2>/dev/null | grep 'heads/main' | awk '{print $1}') && admin --config-path ${MONONOKE_CONFIG_PATH} --local-configerator-path ${DATA_DIR}/configerator --cache-mode disabled --just-knobs-config-path ${DATA_DIR}/justknobs.json bookmarks --repo-name ${repoName} set main $CSID`,
866 ], (line) => {
867 send("log", { step: "import", line });
868 });
869
856870 send("progress", { step: "import", message: "Import complete." });
857871
858872 // Step 3: Restart Mononoke services
859873
cli/src/commands/init.ts
@@ -229,7 +229,8 @@
229229 const cloneTmp = join(dir, "..", `.grove-clone-${name}-${Date.now()}`);
230230 try {
231231 // Clone into a temp dir, then move .sl into the working dir
232 execSync(`sl clone slapi:${name} "${cloneTmp}"`, { stdio: "pipe" });
232 // Pass selectivepulldefault so sl clone pulls the right bookmark (default is "master")
233 execSync(`sl clone --config remotenames.selectivepulldefault=${gitBranch} slapi:${name} "${cloneTmp}"`, { stdio: "pipe" });
233234
234235 // Remove .git and replace with .sl
235236 rmSync(join(dir, ".git"), { recursive: true, force: true });
@@ -239,6 +240,9 @@
239240 const config = buildSlConfig({ ...repo, default_branch: gitBranch }, hub);
240241 writeFileSync(join(dir, ".sl", "config"), config);
241242
243 // Reset dirstate to match existing working copy files
244 execSync(`sl goto ${gitBranch} --clean`, { cwd: dir, stdio: "pipe" });
245
242246 s3.stop("Sapling working copy ready");
243247 } catch (e: any) {
244248 s3.stop("Clone failed");
245249