Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 67d99f7

Browse files
gpongelliLee-W
authored andcommitted
feat(bump): add signed tag support for bump command
1 parent 95e06fb commit 67d99f7

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

‎commitizen/cli.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@
160160
"help": "create annotated tag instead of lightweight one",
161161
"action": "store_true",
162162
},
163+
{
164+
"name": ["--signed-tag", "-st"],
165+
"help": "sign tag instead of lightweight one",
166+
"default": False,
167+
"action": "store_true",
168+
},
163169
{
164170
"name": ["--changelog-to-stdout"],
165171
"action": "store_true",

‎commitizen/commands/bump.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(self, config: BaseConfig, arguments: dict):
4141
"increment",
4242
"bump_message",
4343
"annotated_tag",
44+
"signed_tag",
4445
]
4546
if arguments[key] is not None
4647
},
@@ -233,6 +234,8 @@ def __call__(self): # noqa: C901
233234
new_tag_version,
234235
annotated=self.bump_settings.get("annotated_tag", False)
235236
or bool(self.config.settings.get("annotated_tag", False)),
237+
signed=self.bump_settings.get("signed_tag", False)
238+
or bool(self.config.settings.get("signed_tag", False)),
236239
)
237240
if c.return_code != 0:
238241
raise BumpTagFailedError(c.err)

‎commitizen/git.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
import os
23
from pathlib import Path
34
from tempfile import NamedTemporaryFile
@@ -58,8 +59,13 @@ def from_line(cls, line: str, inner_delimiter: str) -> "GitTag":
5859
return cls(name=name, rev=obj, date=date)
5960

6061

61-
def tag(tag: str, annotated: bool = False) -> cmd.Command:
62-
c = cmd.run(f"git tag -a {tag} -m {tag}" if annotated else f"git tag {tag}")
62+
def tag(tag: str, annotated: bool = False, signed: bool = False) -> cmd.Command:
63+
_opt = ""
64+
if annotated:
65+
_opt = f"-a {tag} -m"
66+
if signed:
67+
_opt = f"-s {tag} -m"
68+
c = cmd.run(f"git tag {_opt} {tag}")
6369
return c
6470

6571

@@ -136,6 +142,14 @@ def tag_exist(tag: str) -> bool:
136142
return tag in c.out
137143

138144

145+
def is_signed_tag(tag: str) -> bool:
146+
c = cmd.run(f"git tag -v {tag}")
147+
_ret = False
148+
if re.match("gpg: Signature made [0-9/:A-Za-z ]*", c.err):
149+
_ret = True
150+
return _ret
151+
152+
139153
def get_latest_tag_name() -> Optional[str]:
140154
c = cmd.run("git describe --abbrev=0 --tags")
141155
if c.err:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /