MCPcopy Create free account
hub / github.com/BillHuang2001/evogit / add_note

Function add_note

python-impl/evogit/utils/git.py:274–296  ·  view source on GitHub ↗

Add a note to the current commit. If overwrite is True, force overwrite the existing note.

(
    config: EvoGitConfig, commit: str, note: str | bytes, overwrite: bool = False
)

Source from the content-addressed store, hash-verified

272
273
274def add_note(
275 config: EvoGitConfig, commit: str, note: str | bytes, overwrite: bool = False
276) -> None:
277 """Add a note to the current commit. If overwrite is True, force overwrite the existing note."""
278 # the note is passed through stdin, so we use `-F -` to let git read from stdin
279 # otherwise, if we use `-m`, and the note is too long, it will result in an error
280 cmd = ["git", "notes", "add", "-F", "-"]
281 if overwrite:
282 cmd.append("-f")
283
284 cmd.append(commit)
285
286 if isinstance(note, str):
287 note = note.encode("utf-8")
288
289 subprocess.run(
290 cmd,
291 cwd=config.git_dir,
292 input=note,
293 check=True,
294 stdout=subprocess.DEVNULL,
295 stderr=subprocess.DEVNULL,
296 )
297
298
299def append_note(config: EvoGitConfig, commit: str, note: str | bytes) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected