fix(6245): bind_repo(moved_from=…) moves the snippet locations recorded in the old repo
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / TypeScript typecheck (push) Successful in 58s
CI & Build / integration (push) Failing after 1m16s
CI & Build / Python tests (push) Successful in 2m33s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / TypeScript typecheck (push) Successful in 58s
CI & Build / integration (push) Failing after 1m16s
CI & Build / Python tests (push) Successful in 2m33s
CI & Build / Build & push image (push) Skipped
A repo renamed on its forge kept every snippet location naming the old repo: the binding and the shape ledger moved, the snippets did not. - snippets.move_location_repo rewrites, on every live snippet of the project, each location whose repo is the old remote in any form (URL, normalized key, "owner/Repo", bare "Repo", compared without case) to the new normalized key. A snippet the caller can only read is listed in read_only and left alone. - Its loop is shared with move_locations through _rewrite_locations, which saves each changed snippet through update_snippet. - bind_repo calls it after the binding moves and reports snippets_moved and snippets_read_only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
from grimoire.mcp._context import current_user_id
|
||||
from grimoire.services import projects as projects_svc
|
||||
from grimoire.services import repo_bindings as repo_bindings_svc
|
||||
from grimoire.services import snippets as snippets_svc
|
||||
|
||||
|
||||
async def bind_repo(
|
||||
@@ -30,9 +31,11 @@ async def bind_repo(
|
||||
pass ref="-" to clear it back to the default branch.
|
||||
|
||||
A repo renamed on its forge has a new remote, and its ledger is stored
|
||||
under the old one. Pass the old remote as `moved_from` and the binding and
|
||||
every shape judgment move to the new name together. Binding the new name
|
||||
without it starts an empty ledger beside the old one.
|
||||
under the old one. Pass the old remote as `moved_from` and the binding,
|
||||
every shape judgment, and every snippet location recorded in the old repo
|
||||
move to the new name together. Binding the new name without it starts an
|
||||
empty ledger beside the old one. A snippet shared with you read-only keeps
|
||||
its location and is listed in `snippets_read_only`; its owner moves it.
|
||||
|
||||
Args:
|
||||
repo_url: the repo's git remote (e.g. the output of
|
||||
@@ -49,11 +52,14 @@ async def bind_repo(
|
||||
if project is None:
|
||||
raise ValueError(f"project {project_id} not found")
|
||||
ref_arg = None if not ref else ("" if ref.strip() == "-" else ref)
|
||||
moved = None
|
||||
moved = snippets = None
|
||||
if moved_from:
|
||||
_, moved = await repo_bindings_svc.move_binding(
|
||||
uid, moved_from, repo_url, project_id,
|
||||
)
|
||||
snippets = await snippets_svc.move_location_repo(
|
||||
uid, project_id, moved_from, repo_url,
|
||||
)
|
||||
binding = await repo_bindings_svc.set_binding(uid, repo_url, project_id, ref_arg)
|
||||
follows = binding.ref or "the default branch"
|
||||
out = {
|
||||
@@ -70,7 +76,12 @@ async def bind_repo(
|
||||
old_key = repo_bindings_svc.normalize_repo_key(moved_from)
|
||||
out["moved_from"] = old_key
|
||||
out["shapes_moved"] = moved
|
||||
out["message"] += f" Moved from `{old_key}` with {moved} shape(s)."
|
||||
out["snippets_moved"] = snippets["moved"]
|
||||
out["snippets_read_only"] = snippets["read_only"]
|
||||
out["message"] += (
|
||||
f" Moved from `{old_key}` with {moved} shape(s) and "
|
||||
f"{len(snippets['moved'])} snippet(s)."
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user