utils: create git_get_branch() from packages.cli
This commit is contained in:
parent
f395ef231b
commit
daff20302a
2 changed files with 7 additions and 3 deletions
5
utils.py
5
utils.py
|
@ -79,6 +79,11 @@ def git(cmd: list[str], dir: Optional[str] = None, capture_output=False, user: O
|
|||
return result
|
||||
|
||||
|
||||
def git_get_branch(path) -> str:
|
||||
result = git(['branch', '--show-current'], dir=path, capture_output=True)
|
||||
return result.stdout.decode().strip()
|
||||
|
||||
|
||||
def log_or_exception(raise_exception: bool, msg: str, exc_class=Exception, log_level=logging.WARNING):
|
||||
if raise_exception:
|
||||
raise exc_class(msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue