Skip to content

Commit eda818c

Browse files
committed
cmd/git(fix[GitNoteCmd]): Propagate custom ref to note commands
why: GitNotesManager stores a custom ref but GitNoteCmd objects created by ls() ignored it, causing show/remove operations to always target refs/notes/commits instead of the manager's ref. what: - Add ref parameter to GitNoteCmd.__init__ - Pass --ref flag in GitNoteCmd.run() when ref is set - Update GitNotesManager.ls() to pass ref to GitNoteCmd instances
1 parent 1b18d7a commit eda818c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/libvcs/cmd/git.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6975,6 +6975,7 @@ def __init__(
69756975
cmd: Git | None = None,
69766976
object_sha: str,
69776977
note_sha: str | None = None,
6978+
ref: str | None = None,
69786979
) -> None:
69796980
"""Lite, typed, pythonic wrapper for a git-notes(1) entry.
69806981
@@ -6986,6 +6987,8 @@ def __init__(
69866987
SHA of the object this note is attached to.
69876988
note_sha :
69886989
SHA of the note blob itself.
6990+
ref :
6991+
Notes ref to use (default: refs/notes/commits).
69896992
69906993
Examples
69916994
--------
@@ -7006,6 +7009,7 @@ def __init__(
70067009

70077010
self.object_sha = object_sha
70087011
self.note_sha = note_sha
7012+
self.ref = ref
70097013

70107014
def __repr__(self) -> str:
70117015
"""Representation of a git note."""
@@ -7026,11 +7030,17 @@ def run(
70267030
Wraps `git notes <https://git-scm.com/docs/git-notes>`_.
70277031
"""
70287032
local_flags = local_flags if isinstance(local_flags, list) else []
7033+
7034+
# Add ref option if specified
7035+
ref_flags: list[str] = []
7036+
if self.ref is not None:
7037+
ref_flags.extend(["--ref", self.ref])
7038+
70297039
if command is not None:
70307040
local_flags.insert(0, command)
70317041

70327042
return self.cmd.run(
7033-
["notes", *local_flags],
7043+
["notes", *ref_flags, *local_flags],
70347044
check_returncode=check_returncode,
70357045
log_in_real_time=log_in_real_time,
70367046
**kwargs,
@@ -7554,6 +7564,7 @@ def ls(self) -> QueryList[GitNoteCmd]:
75547564
cmd=self.cmd,
75557565
object_sha=object_sha,
75567566
note_sha=note_sha,
7567+
ref=self.ref,
75577568
)
75587569
for note_sha, object_sha in raw_notes
75597570
],

0 commit comments

Comments
 (0)