Skip to content

Commit 9dde1d5

Browse files
author
Steven Silvester
authored
Merge pull request #115 from fcollonval/ft/set-commit-message
Allow to set commit message
2 parents 9da80cd + 66f7025 commit 9dde1d5

File tree

4 files changed

+55
-12
lines changed

4 files changed

+55
-12
lines changed

jupyter_releaser/cli.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,27 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
402402

403403
@main.command()
404404
@add_options(dist_dir_options)
405+
@click.option(
406+
"--release-message",
407+
envvar="RH_RELEASE_MESSAGE",
408+
default="Publish {version}",
409+
help="The message to use for the release commit",
410+
)
411+
@click.option(
412+
"--tag-message",
413+
envvar="RH_TAG_MESSAGE",
414+
default="Release {tag_name}",
415+
help="The message to use for the release tag",
416+
)
405417
@click.option(
406418
"--no-git-tag-workspace",
407419
is_flag=True,
408420
help="Whether to skip tagging npm workspace packages",
409421
)
410422
@use_checkout_dir()
411-
def tag_release(dist_dir, no_git_tag_workspace):
423+
def tag_release(dist_dir, release_message, tag_message, no_git_tag_workspace):
412424
"""Create release commit and tag"""
413-
lib.tag_release(dist_dir, no_git_tag_workspace)
425+
lib.tag_release(dist_dir, release_message, tag_message, no_git_tag_workspace)
414426

415427

416428
@main.command()
@@ -425,6 +437,12 @@ def tag_release(dist_dir, no_git_tag_workspace):
425437
envvar="RH_POST_VERSION_SPEC",
426438
help="The post release version (usually dev)",
427439
)
440+
@click.option(
441+
"--post-version-message",
442+
default="Bumped version to {post_version}",
443+
envvar="RH_POST_VERSION_MESSAGE",
444+
help="The post release message",
445+
)
428446
@click.argument("assets", nargs=-1)
429447
@use_checkout_dir()
430448
def draft_release(
@@ -437,6 +455,7 @@ def draft_release(
437455
dist_dir,
438456
dry_run,
439457
post_version_spec,
458+
post_version_message,
440459
assets,
441460
):
442461
"""Publish Draft GitHub release"""
@@ -450,6 +469,7 @@ def draft_release(
450469
dist_dir,
451470
dry_run,
452471
post_version_spec,
472+
post_version_message,
453473
assets,
454474
)
455475

jupyter_releaser/lib.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,20 @@ def make_changelog_pr(auth, branch, repo, title, commit_message, body, dry_run=F
169169
util.actions_output("pr_url", pull.html_url)
170170

171171

172-
def tag_release(dist_dir, no_git_tag_workspace):
172+
def tag_release(dist_dir, release_message, tag_message, no_git_tag_workspace):
173173
"""Create release commit and tag"""
174174
# Get the new version
175175
version = util.get_version()
176176

177177
# Create the release commit
178-
util.create_release_commit(version, dist_dir)
178+
util.create_release_commit(version, release_message, dist_dir)
179179

180180
# Create the annotated release tag
181181
tag_name = f"v{version}"
182-
util.run(f'git tag {tag_name} -a -m "Release {tag_name}"')
182+
tag_message = tag_message.format(tag_name=tag_name)
183+
util.run(f'git tag {tag_name} -a -m "{tag_message}"')
183184

184-
# Create annotated release tags for workspace packages if given
185+
# Create release tags for workspace packages if given
185186
if not no_git_tag_workspace:
186187
npm.tag_workspace_packages()
187188

@@ -196,6 +197,7 @@ def draft_release(
196197
dist_dir,
197198
dry_run,
198199
post_version_spec,
200+
post_version_message,
199201
assets,
200202
):
201203
"""Publish Draft GitHub release and handle post version bump"""
@@ -209,8 +211,7 @@ def draft_release(
209211
# Bump to post version if given
210212
if post_version_spec:
211213
post_version = bump_version(post_version_spec, version_cmd)
212-
213-
util.log(f"Bumped version to {post_version}")
214+
util.log(post_version_message.format(post_version=post_version))
214215
util.run(f'git commit -a -m "Bump to {post_version}"')
215216

216217
if dry_run:

jupyter_releaser/tests/test_cli.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,14 @@ def test_list_envvars(runner):
159159
npm-install-options: RH_NPM_INSTALL_OPTIONS
160160
npm-token: NPM_TOKEN
161161
output: RH_CHANGELOG_OUTPUT
162+
post-version-message: RH_POST_VERSION_MESSAGE
162163
post-version-spec: RH_POST_VERSION_SPEC
163164
ref: RH_REF
165+
release-message: RH_RELEASE_MESSAGE
164166
repo: RH_REPOSITORY
165167
resolve-backports: RH_RESOLVE_BACKPORTS
166168
since: RH_SINCE
169+
tag-message: RH_TAG_MESSAGE
167170
twine-cmd: TWINE_COMMAND
168171
username: GITHUB_ACTOR
169172
version-cmd: RH_VERSION_COMMAND
@@ -441,7 +444,15 @@ def test_tag_release(py_package, runner, build_mock, git_prep):
441444
# Create the dist files
442445
util.run("python -m build .", cwd=util.CHECKOUT_NAME)
443446
# Tag the release
444-
runner(["tag-release"])
447+
runner(
448+
[
449+
"tag-release",
450+
"--release-message",
451+
"hi {version}",
452+
"--tag-message",
453+
"no thanks",
454+
]
455+
)
445456

446457
log = get_log()
447458
assert "before-tag-release" in log
@@ -450,7 +461,16 @@ def test_tag_release(py_package, runner, build_mock, git_prep):
450461

451462
def test_draft_release_dry_run(py_dist, mocker, runner, open_mock, git_prep):
452463
# Publish the release - dry run
453-
runner(["draft-release", "--dry-run", "--post-version-spec", "1.1.0.dev0"])
464+
runner(
465+
[
466+
"draft-release",
467+
"--dry-run",
468+
"--post-version-spec",
469+
"1.1.0.dev0",
470+
"--post-version-message",
471+
"haha",
472+
]
473+
)
454474
open_mock.assert_not_called()
455475

456476
log = get_log()

jupyter_releaser/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ def compute_sha256(path):
161161
return sha256.hexdigest()
162162

163163

164-
def create_release_commit(version, dist_dir="dist"):
164+
def create_release_commit(version, release_message=None, dist_dir="dist"):
165165
"""Generate a release commit that has the sha256 digests for the release files"""
166-
cmd = f'git commit -am "Publish {version}" -m "SHA256 hashes:"'
166+
release_message = release_message or "Publish {version}"
167+
release_message = release_message.format(version=version)
168+
cmd = f'git commit -am "{release_message}" -m "SHA256 hashes:"'
167169

168170
shas = dict()
169171

0 commit comments

Comments
 (0)