Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tbump should be able to make signed tag #133 #170

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ __pycache__
.mypy_cache/

.vscode
.idea
2 changes: 1 addition & 1 deletion tbump.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ regex = '''


[git]
message_template = "Bump to {new_version}"
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"


Expand Down
4 changes: 4 additions & 0 deletions tbump/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Config:
git_tag_template: str
git_message_template: str
atomic_push: bool
sign: bool

files: List[File]
hooks: List[Hook]
Expand Down Expand Up @@ -201,6 +202,7 @@ def validate_re(regex: str) -> str:
"message_template": str,
"tag_template": str,
schema.Optional("atomic_push"): bool,
schema.Optional("sign"): bool,
},
"file": [file_schema],
schema.Optional("field"): [field_schema],
Expand Down Expand Up @@ -296,6 +298,7 @@ def from_parsed_config(parsed: dict) -> Config:
git_message_template = parsed["git"]["message_template"]
git_tag_template = parsed["git"]["tag_template"]
atomic_push = parsed["git"].get("atomic_push", True)
sign = parsed["git"].get("sign", False)
version_regex = re.compile(parsed["version"]["regex"], re.VERBOSE)
files = []
for file_dict in parsed["file"]:
Expand Down Expand Up @@ -328,6 +331,7 @@ def from_parsed_config(parsed: dict) -> Config:
git_message_template=git_message_template,
git_tag_template=git_tag_template,
atomic_push=atomic_push,
sign=sign,
fields=fields,
files=files,
hooks=hooks,
Expand Down
23 changes: 19 additions & 4 deletions tbump/git_bumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class GitBumper:
def __init__(self, options: GitBumperOptions, operations: List[str]):
self.repo_path = options.working_path
self.atomic_push = True
self.sign = False
self.tag_message = options.tag_message
self.tag_template = ""
self.message_template = ""
Expand All @@ -88,9 +89,12 @@ def set_config(self, config: Config) -> None:
self.message_template = config.git_message_template
# atomic_push is True by default, and must be explicitely
# disabled in the configuration:
if config.atomic_push is False:
if not config.atomic_push:
self.atomic_push = False

if config.sign:
self.sign = True

def run_git(self, *args: str, verbose: bool = False) -> None:
return run_git(self.repo_path, *args, verbose=verbose)

Expand Down Expand Up @@ -160,9 +164,20 @@ def get_commands(self, new_version: str) -> List[Command]:
else:
tag_message = tag_name

self.add_command(
res, "tag", "--annotate", "--message", tag_message, tag_name
)
if not self.sign:
self.add_command(
res, "tag", "--annotate", "--message", tag_message, tag_name
)
else:
self.add_command(
res,
"tag",
"--sign",
"--annotate",
"--message",
tag_message,
tag_name,
)
if "push_commit" in self.operations and "push_tag" in self.operations:
if self.atomic_push:
self.add_command(
Expand Down