Skip to content

Commit 22cc7c3

Browse files
committed
More Cleanup
1 parent 0b06cb9 commit 22cc7c3

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

.github/workflows/draft-changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
id: draft-changelog
3737
uses: ./.github/actions/draft-changelog
3838
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
39+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
4040
version_spec: ${{ github.event.inputs.version_spec }}
4141
target: ${{ github.event.inputs.target }}
4242
branch: ${{ github.event.inputs.branch }}

jupyter_releaser/cli.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,18 @@ def invoke(self, ctx):
6262
if param.envvar and os.environ.get(param.envvar):
6363
continue
6464
name = param.name
65-
if name in options:
65+
if name in options or name.replace("_", "-") in options:
6666
arg = f"--{name.replace('_', '-')}"
6767
# Defer to cli overrides
6868
if arg not in ctx.args:
69-
ctx.args.append(arg)
70-
ctx.args.append(options[name])
69+
val = options.get(name, options.get(name.replace("_", "-")))
70+
if isinstance(val, list):
71+
for v in val:
72+
ctx.args.append(arg)
73+
ctx.args.append(v)
74+
else:
75+
ctx.args.append(arg)
76+
ctx.args.append(val)
7177

7278
# Handle before hooks
7379
before = f"before-{cmd_name}"
@@ -330,11 +336,6 @@ def check_manifest():
330336
@click.option(
331337
"--ignore-links",
332338
multiple=True,
333-
default=[
334-
"https://github.com/.*/(pull|issues)/.*",
335-
"https://github.com/search?",
336-
"http://localhost.*",
337-
],
338339
help="Ignore links based on regex pattern(s)",
339340
)
340341
@click.option(

jupyter_releaser/lib.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
5656
cmd += f' --ignore-glob "{spec}"'
5757
ignored.extend(glob(spec, recursive=True))
5858

59+
ignore_links = list(ignore_links) + [
60+
"https://github.com/.*/(pull|issues)/.*",
61+
"https://github.com/search?",
62+
"http://localhost.*",
63+
]
64+
5965
for spec in ignore_links:
6066
cmd += f' --check-links-ignore "{spec}"'
6167

@@ -67,12 +73,14 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
6773
matched = glob(f"**/*{ext}", recursive=True)
6874
files.extend(m for m in matched if not m in ignored)
6975

70-
cmd += ' "' + '" "'.join(files) + '"'
71-
72-
try:
73-
util.run(cmd)
74-
except Exception:
75-
util.run(cmd + " --lf")
76+
for f in files:
77+
file_cmd = cmd + f' "{f}"'
78+
try:
79+
util.run(file_cmd)
80+
except Exception as e:
81+
# Return code 5 means no tests were run (no links found)
82+
if e.returncode != 5:
83+
util.run(file_cmd + " --lf")
7684

7785

7886
def draft_changelog(version_spec, branch, repo, auth, dry_run):

jupyter_releaser/tests/test_cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,13 @@ def test_check_links(py_package, runner):
242242
text = readme.read_text(encoding="utf-8")
243243
text += "\nhttps://apod.nasa.gov/apod/astropix.html"
244244
readme.write_text(text, encoding="utf-8")
245-
util.run("git commit -a -m 'update readme'")
245+
246+
pyproject = util.toml.loads(util.PYPROJECT.read_text(encoding="utf-8"))
247+
pyproject["tool"] = {"jupyter-releaser": dict()}
248+
pyproject["tool"]["jupyter-releaser"]["options"] = {"ignore-glob": ["FOO.md"]}
249+
util.PYPROJECT.write_text(util.toml.dumps(pyproject), encoding="utf-8")
250+
251+
util.run("git commit -a -m 'update files'")
246252

247253
runner(["prep-git", "--git-url", py_package])
248254
runner(["check-links"])
@@ -253,7 +259,7 @@ def test_check_links(py_package, runner):
253259
bar = Path(util.CHECKOUT_NAME) / "BAR BAZ.md"
254260
bar.write_text("")
255261

256-
runner(["check-links", "--ignore-glob", "FOO.md"])
262+
runner(["check-links"])
257263

258264

259265
def test_check_changelog(py_package, tmp_path, mocker, runner, git_prep):

0 commit comments

Comments
 (0)