Skip to content

Commit 68c4200

Browse files
committed
Don't request metadata uselessly
1 parent b6b9d60 commit 68c4200

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

jupyter_releaser/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,11 @@ def bump_version(version_spec, version_cmd, changelog_path, python_packages):
379379
@add_options(auth_options)
380380
@add_options(changelog_path_options)
381381
@add_options(release_url_options)
382+
@add_options(silent_option)
382383
@use_checkout_dir()
383-
def extract_changelog(dry_run, auth, changelog_path, release_url):
384+
def extract_changelog(dry_run, auth, changelog_path, release_url, silent):
384385
"""Extract the changelog entry."""
385-
lib.extract_changelog(dry_run, auth, changelog_path, release_url)
386+
lib.extract_changelog(dry_run, auth, changelog_path, release_url, silent)
386387

387388

388389
@main.command()
@@ -546,6 +547,7 @@ def tag_release(dist_dir, release_message, tag_format, tag_message, no_git_tag_w
546547
@add_options(dist_dir_options)
547548
@add_options(dry_run_options)
548549
@add_options(release_url_options)
550+
@add_options(silent_option)
549551
@add_options(post_version_spec_options)
550552
@click.argument("assets", nargs=-1)
551553
@use_checkout_dir()
@@ -561,6 +563,7 @@ def populate_release(
561563
release_url,
562564
post_version_spec,
563565
post_version_message,
566+
silent,
564567
assets,
565568
):
566569
"""Populate a release."""
@@ -577,6 +580,7 @@ def populate_release(
577580
post_version_spec,
578581
post_version_message,
579582
assets,
583+
silent,
580584
)
581585

582586

jupyter_releaser/lib.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def populate_release(
231231
post_version_spec,
232232
post_version_message,
233233
assets,
234+
silent=False,
234235
):
235236
"""Populate release assets and push tags and commits"""
236237
branch = branch or util.get_branch()
@@ -251,13 +252,6 @@ def populate_release(
251252
release = util.release_for_url(gh, release_url)
252253

253254
# if the release is silent, the changelog source of truth is the GitHub release
254-
util.log(f"Assets {assets}")
255-
silent = False
256-
for asset in assets:
257-
asset_path = Path(asset)
258-
if asset_path.name == util.METADATA_JSON.name:
259-
metadata = json.loads(asset_path.read_text(encoding="utf-8"))
260-
silent = metadata.get("silent", False)
261255
body = release.body if silent else changelog.extract_current(changelog_path)
262256
util.log(f"release is silent: {silent}")
263257
util.log(f"populate-release release.body: {release.body[100:]}")
@@ -550,7 +544,7 @@ def prep_git(ref, branch, repo, auth, username, url): # noqa
550544
return branch
551545

552546

553-
def extract_changelog(dry_run, auth, changelog_path, release_url):
547+
def extract_changelog(dry_run, auth, changelog_path, release_url, silent=False):
554548
"""Extract the changelog from the draft GH release body and update it.
555549
556550
> If the release must is silent, the changelog entry will be replaced by
@@ -560,10 +554,6 @@ def extract_changelog(dry_run, auth, changelog_path, release_url):
560554
gh = util.get_gh_object(dry_run=dry_run, owner=match["owner"], repo=match["repo"], token=auth)
561555
release = util.release_for_url(gh, release_url)
562556

563-
# Check for silent status here to avoid request to often the GitHub API
564-
metadata = util.extract_metadata_from_release_url(gh, release.html_url, auth)
565-
silent = metadata.get("silent", False)
566-
567557
changelog_text = mdformat.text(release.body)
568558
changelog.update_changelog(changelog_path, changelog_text, silent=silent)
569559

jupyter_releaser/mock_github.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ def list_releases(owner: str, repo: str) -> List[Release]:
148148
@app.get("/repos/{owner}/{repo}/releases/tags/{tag}")
149149
def get_release_by_tag(owner: str, repo: str, tag: str) -> Release:
150150
"""https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name"""
151-
r = next(filter(lambda r: r.tag_name == tag, releases.values()))
152-
print(r)
153-
return r
151+
return next(filter(lambda r: r.tag_name == tag, releases.values()))
154152

155153

156154
@app.post("/repos/{owner}/{repo}/releases")

0 commit comments

Comments
 (0)