Reproduce stale upstream configuration with real local Git repositories, including the already-matching pin fast path. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
+9
-4
@@ -73,13 +73,12 @@ def engine_identity() -> str:
|
||||
def fork():
|
||||
"""Initialize the exact gitlink; never replace a modified developer checkout."""
|
||||
expected = engine_commit()
|
||||
matched = False
|
||||
if (FORK / ".git").exists():
|
||||
current = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=FORK, text=True).strip()
|
||||
if current == expected:
|
||||
print(f"horizon/: закреплённый коммит {expected}")
|
||||
return
|
||||
matched = current == expected
|
||||
dirty = subprocess.check_output(["git", "status", "--porcelain"], cwd=FORK, text=True).strip()
|
||||
if dirty:
|
||||
if not matched and dirty:
|
||||
sys.exit("horizon/: есть изменения при другом закреплённом SHA; сохраните их перед обновлением сабмодуля")
|
||||
if (FORK / ".git").is_dir():
|
||||
# Migrate the old standalone clone without deleting it or any local branches.
|
||||
@@ -88,6 +87,12 @@ def fork():
|
||||
run(["git", "remote", "set-url", "origin", url], cwd=FORK)
|
||||
elif FORK.exists() and any(FORK.iterdir()):
|
||||
sys.exit("horizon/: непустой каталог без Git; сохраните его перед инициализацией сабмодуля")
|
||||
# Existing clones cache the previous upstream URL in local Git configuration.
|
||||
# Synchronize even when HEAD already matches: the next pin may exist only in our fork.
|
||||
run(["git", "submodule", "sync", "--recursive", "--", "horizon"], cwd=ROOT)
|
||||
if matched:
|
||||
print(f"horizon/: закреплённый коммит {expected}")
|
||||
return
|
||||
run(["git", "submodule", "update", "--init", "--recursive", "--", "horizon"], cwd=ROOT)
|
||||
current = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=FORK, text=True).strip()
|
||||
if current != expected:
|
||||
|
||||
Reference in New Issue
Block a user