spork-create: bail if local clone already exists
Trying to add remotes to an existing clone gets the origin wrong. Better to error out and let the user handle it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6ecfaf02b6
commit
ee6f516b2b
1 changed files with 29 additions and 43 deletions
|
|
@ -354,28 +354,14 @@ def main(
|
||||||
else:
|
else:
|
||||||
local_path = LOCAL_BASE / repo_name
|
local_path = LOCAL_BASE / repo_name
|
||||||
if local_path.exists():
|
if local_path.exists():
|
||||||
console.print(f"[yellow]Local directory already exists:[/yellow] {local_path}")
|
console.print(
|
||||||
console.print("Setting up remotes on existing clone...")
|
f"[red]Error:[/red] Local directory already exists: [bold]{local_path}[/bold]"
|
||||||
# Add missing remotes
|
|
||||||
mirror_url = f"{FORGE_SSH}/{MIRROR_ORG}/{repo_name}.git"
|
|
||||||
subprocess.run(
|
|
||||||
["git", "remote", "add", "mirror", mirror_url],
|
|
||||||
cwd=local_path,
|
|
||||||
capture_output=True, # may already exist
|
|
||||||
)
|
)
|
||||||
if upstream_url and upstream_url != "unknown":
|
console.print(
|
||||||
subprocess.run(
|
"Remove it first or use [dim]--no-clone[/dim] to skip local setup."
|
||||||
["git", "remote", "add", "upstream", upstream_url],
|
|
||||||
cwd=local_path,
|
|
||||||
capture_output=True,
|
|
||||||
)
|
)
|
||||||
subprocess.run(
|
raise SystemExit(1)
|
||||||
["git", "fetch", "--all"],
|
|
||||||
cwd=local_path,
|
|
||||||
check=True,
|
|
||||||
capture_output=True,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
console.print(f"Cloning to {local_path}...")
|
console.print(f"Cloning to {local_path}...")
|
||||||
clone_url = f"{FORGE_SSH}/{OWNER}/{repo_name}.git"
|
clone_url = f"{FORGE_SSH}/{OWNER}/{repo_name}.git"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue