Skip to content

Commit 73cacdd

Browse files
authored
Merge pull request #27 from jtpio/cleanup
More Cleanup in Preparation for Usage with Lumino
2 parents bbbb83b + 7a07446 commit 73cacdd

File tree

7 files changed

+27
-12
lines changed

7 files changed

+27
-12
lines changed

jupyter_releaser/changelog.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ def get_version_entry(
6565
str
6666
A formatted changelog entry with markers
6767
"""
68-
tags = util.run(f"git --no-pager tag --sort=-creatordate --merged {branch}")
69-
if not tags: # pragma: no cover
70-
raise ValueError(f"No tags found on branch {branch}")
68+
if not since:
69+
tags = util.run(f"git --no-pager tag --sort=-creatordate --merged {branch}")
70+
if tags:
71+
since = tags.splitlines()[0]
7172

72-
since = since or tags.splitlines()[0]
7373
branch = branch.split("/")[-1]
7474
util.log(f"Getting changes to {repo} since {since} on branch {branch}...")
7575

jupyter_releaser/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,16 @@ def build_changelog(ref, branch, repo, auth, changelog_path, since, resolve_back
255255
@add_options(branch_options)
256256
@add_options(since_options)
257257
@add_options(auth_options)
258+
@add_options(changelog_path_options)
258259
@add_options(dry_run_options)
259260
@use_checkout_dir()
260-
def draft_changelog(version_spec, ref, branch, repo, since, auth, dry_run):
261+
def draft_changelog(
262+
version_spec, ref, branch, repo, since, auth, changelog_path, dry_run
263+
):
261264
"""Create a changelog entry PR"""
262-
lib.draft_changelog(version_spec, branch, repo, since, auth, dry_run)
265+
lib.draft_changelog(
266+
version_spec, branch, repo, since, auth, changelog_path, dry_run
267+
)
263268

264269

265270
@main.command()

jupyter_releaser/lib.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
7272
files = []
7373
for ext in [".md", ".rst", ".ipynb"]:
7474
matched = glob(f"**/*{ext}", recursive=True)
75-
files.extend(m for m in matched if not m in ignored)
75+
files.extend(m for m in matched if not m in ignored and "node_modules" not in m)
7676

7777
for f in files:
7878
file_cmd = cmd + f' "{f}"'
@@ -84,7 +84,7 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
8484
util.run(file_cmd + " --lf")
8585

8686

87-
def draft_changelog(version_spec, branch, repo, since, auth, dry_run):
87+
def draft_changelog(version_spec, branch, repo, since, auth, changelog_path, dry_run):
8888
"""Create a changelog entry PR"""
8989
repo = repo or util.get_repo()
9090
branch = branch or util.get_branch()
@@ -97,6 +97,9 @@ def draft_changelog(version_spec, branch, repo, since, auth, dry_run):
9797
# Check out any unstaged files from version bump
9898
util.run("git checkout -- .")
9999

100+
current = changelog.extract_current(changelog_path)
101+
util.log(f"\n\nCurrent Changelog Entry:\n{current}")
102+
100103
title = f"{changelog.PR_PREFIX} for {version} on {branch}"
101104
commit_message = f'git commit -a -m "{title}"'
102105
body = title

jupyter_releaser/npm.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ def get_package_versions(version):
152152
message += f'\nnpm version: {data["name"]}: {data["version"]}'
153153
if "workspaces" in data:
154154
message += "\nnpm workspace versions:"
155-
packages = data["workspaces"].get("packages", [])
155+
156+
if isinstance(data["workspaces"], dict):
157+
packages = []
158+
for value in data["workspaces"].values():
159+
packages.extend(value)
160+
else:
161+
packages = data["workspaces"]
162+
156163
for pattern in packages:
157164
for path in glob(pattern, recursive=True):
158165
text = Path(path).joinpath("package.json").read_text()

jupyter_releaser/tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def git_repo(tmp_path):
6060

6161
run("git add .")
6262
run('git commit -m "foo"')
63-
run("git tag v0.0.1")
6463
run(f"git remote add origin {util.normalize_path(tmp_path)}")
6564
run("git push origin foo")
6665
run("git remote set-head origin foo")

jupyter_releaser/tests/test_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_get_changelog_version_entry(py_package, mocker):
5454
branch = "foo"
5555
resp = changelog.get_version_entry(branch, "bar/baz", version)
5656
mocked_gen.assert_called_with(
57-
"bar/baz", since="v0.0.1", kind="pr", branch=branch, heading_level=2, auth=None
57+
"bar/baz", since=None, kind="pr", branch=branch, heading_level=2, auth=None
5858
)
5959

6060
assert f"## {version}" in resp
@@ -66,7 +66,7 @@ def test_get_changelog_version_entry(py_package, mocker):
6666
)
6767
mocked_gen.assert_called_with(
6868
"bar/baz",
69-
since="v0.0.1",
69+
since=None,
7070
kind="pr",
7171
branch=branch,
7272
heading_level=2,

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ install_requires =
4040
setuptools
4141
tbump
4242
toml
43+
tomlkit<0.7.1
4344
twine
4445

4546
[options.extras_require]

0 commit comments

Comments
 (0)