Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ def from_line(cls, line: str, inner_delimiter: str) -> GitTag:
def tag(
tag: str, annotated: bool = False, signed: bool = False, msg: str | None = None
) -> cmd.Command:
_opt = ""
if annotated:
_opt = f"-a {tag} -m"
if signed:
_opt = f"-s {tag} -m"
if not annotated and not signed:
return cmd.run(f"git tag {tag}")

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


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