Skip to content

Commit af50d85

Browse files
bearomorphismLee-W
authored andcommitted
refactor(git): simplify tag logic
1 parent 303d2eb commit af50d85

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

commitizen/git.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,14 @@ def from_line(cls, line: str, inner_delimiter: str) -> GitTag:
160160
def tag(
161161
tag: str, annotated: bool = False, signed: bool = False, msg: str | None = None
162162
) -> cmd.Command:
163-
_opt = ""
164-
if annotated:
165-
_opt = f"-a {tag} -m"
166-
if signed:
167-
_opt = f"-s {tag} -m"
163+
if not annotated and not signed:
164+
return cmd.run(f"git tag {tag}")
168165

169166
# according to https://git-scm.com/book/en/v2/Git-Basics-Tagging,
170167
# we're not able to create lightweight tag with message.
171168
# by adding message, we make it a annotated tags
172-
return cmd.run(f'git tag {_opt} "{tag if _opt == "" or msg is None else msg}"')
169+
option = "-s" if signed else "-a" # The else case is for annotated tags
170+
return cmd.run(f'git tag {option} {tag} -m "{msg or tag}"')
173171

174172

175173
def add(*args: str) -> cmd.Command:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy