mirror of
https://github.com/davidism/modify-repos.git
synced 2025-07-07 19:35:34 +00:00
add repo.commit shortcut
This commit is contained in:
parent
3e778fb77e
commit
0c6e5ed62b
2 changed files with 16 additions and 0 deletions
|
@ -4,6 +4,7 @@ Unreleased
|
|||
|
||||
- If a PR already exists from a previous failed run, force push to update the
|
||||
existing branch and PR.
|
||||
- Add shortcut `repo.commit(message)` method.
|
||||
|
||||
## Version 0.1.1
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from shutil import which
|
|||
from subprocess import CompletedProcess
|
||||
|
||||
from ..utils import run_cmd
|
||||
from ..utils import wrap_text
|
||||
from .base import Repo
|
||||
|
||||
|
||||
|
@ -64,6 +65,20 @@ class GitRepo(Repo):
|
|||
self.git_cmd("merge", "--ff-only", self.script.branch)
|
||||
self.git_cmd("push")
|
||||
|
||||
def commit(self, message: str, add: bool = False) -> None:
|
||||
"""Create a commit with the given message.
|
||||
|
||||
:param message: The commit message.
|
||||
:param add: Update tracked files while committing. Disabled by default.
|
||||
Alternatively, call {meth}`add_files` first.
|
||||
"""
|
||||
args = ["commit", "--message", wrap_text(message, width=72)]
|
||||
|
||||
if add:
|
||||
args.insert(1, "-a")
|
||||
|
||||
self.git_cmd(*args)
|
||||
|
||||
def add_files(
|
||||
self, *items: str | Path, update: bool = False, all: bool = False
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue