From 56bc30f0fd411718d0593c618e5acb0a613cda73 Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Tue, 12 Mar 2024 14:55:24 +0800 Subject: feat(tag): add support for git tag --- src/ipm/utils/git.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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 ")}[/]") -- cgit v1.2.3-70-g09d2