diff options
| author | 2024-03-12 14:55:24 +0800 | |
|---|---|---|
| committer | 2024-03-12 14:55:24 +0800 | |
| commit | 56bc30f0fd411718d0593c618e5acb0a613cda73 (patch) | |
| tree | 850d0a2a8cd5b5f077913412514716aa5fc39067 | |
| parent | 4446b5d888bbf8fc64c480668aa7d4cab0cfdb7b (diff) | |
| download | ipm-56bc30f0fd411718d0593c618e5acb0a613cda73.tar.gz ipm-56bc30f0fd411718d0593c618e5acb0a613cda73.zip | |
feat(tag): add support for git tag
| -rw-r--r-- | src/ipm/utils/git.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ipm/utils/git.py b/src/ipm/utils/git.py index 20f9d70..59d3f72 100644 --- a/src/ipm/utils/git.py +++ b/src/ipm/utils/git.py @@ -1,5 +1,6 @@ from pathlib import Path -from git import Repo +from ipm.exceptions import RuntimeError +from git import GitCommandError, Repo import os @@ -18,3 +19,11 @@ def get_user_name_email(): def git_init(target_path: Path): return Repo.init(target_path) + + +def git_tag(target_path: Path, tag: str): + repo = Repo(target_path) + try: + repo.create_tag("v" + tag) + except GitCommandError as err: + raise RuntimeError(f"创建 Tag 时出现异常: [red]{err.stderr.strip("\n ")}[/]") |
