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
)
| 272 | |
| 273 | |
| 274 | def 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 | |
| 299 | def append_note(config: EvoGitConfig, commit: str, note: str | bytes) -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected