Skip to content

Commit

Permalink
Merge pull request #108 from fcollonval/fix/cleanup
Browse files Browse the repository at this point in the history
More Cleanup
  • Loading branch information
Steven Silvester authored Aug 18, 2021
2 parents d515b1d + c9abdaf commit b93c650
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches: ["*"]
pull_request:
branches: ["*"]
release:
types: [published]
schedule:
- cron: "0 0 * * *"

Expand Down
20 changes: 4 additions & 16 deletions jupyter_releaser/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ def format_pr_entry(target, number, auth=None):


def get_version_entry(
branch,
repo,
version,
*,
since=None,
until=None,
auth=None,
resolve_backports=False,
remote="origin",
branch, repo, version, *, since=None, until=None, auth=None, resolve_backports=False
):
"""Get a changelog for the changes since the last tag on the given branch.
Expand All @@ -69,8 +61,6 @@ def get_version_entry(
The GitHub authorization token
resolve_backports: bool, optional
Whether to resolve backports to the original PR
remote: str, optional
The remote target (default is origin)
Returns
-------
Expand All @@ -80,17 +70,15 @@ def get_version_entry(

if not since:
tags = util.run(
f"git --no-pager tag --sort=-creatordate --merged {remote}/{branch}",
quiet=True,
f"git --no-pager tag --sort=-creatordate --merged {branch}", quiet=True
)
if tags:
since = tags.splitlines()[0]

util.log(f"Getting changes to {repo} since {since} on branch {branch}...")

until = until or util.run(
f'git --no-pager log -n 1 {remote}/{branch} --pretty=format:"%H"'
)
until = until or util.run(f'git --no-pager log -n 1 {branch} --pretty=format:"%H"')

until = until.replace("%", "")

md = generate_activity_md(
Expand Down
4 changes: 3 additions & 1 deletion jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ def publish_assets(dist_dir, npm_token, npm_cmd, twine_cmd, dry_run):
os.environ.setdefault("TWINE_USERNAME", "__token__")

if len(glob(f"{dist_dir}/*.tgz")):
npm.handle_npm_config(npm_token, dist_dir)
npm.handle_npm_config(npm_token, os.getcwd())
if npm_token:
util.run("npm whoami", cwd=os.getcwd())

found = False
for path in sorted(glob(f"{dist_dir}/*.*")):
Expand Down
1 change: 1 addition & 0 deletions jupyter_releaser/npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def handle_npm_config(npm_token, dist_dir):
text += f"\n{registry}:_authToken={npm_token}"
if npmrc.exists():
text = npmrc.read_text(encoding="utf-8") + text
util.log(f"writing npm config to {npmrc}:\n{text}")
npmrc.write_text(text, encoding="utf-8")


Expand Down
2 changes: 0 additions & 2 deletions jupyter_releaser/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,6 @@ def wrapped(cmd, **kwargs):
runner(
[
"publish-assets",
"--npm-token",
"abc",
"--npm-cmd",
"npm publish --dry-run",
"--dist-dir",
Expand Down
8 changes: 8 additions & 0 deletions jupyter_releaser/tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import os
import shutil
from pathlib import Path

import toml

from jupyter_releaser import changelog
from jupyter_releaser import npm
from jupyter_releaser import util
from jupyter_releaser.tests import util as testutil
from jupyter_releaser.util import run
Expand Down Expand Up @@ -108,6 +110,12 @@ def test_create_release_commit_hybrid(py_package, build_mock):
assert util.normalize_path("dist/foo-0.0.2a0.tar.gz") in shas


def test_handle_npm_config(npm_package):
npm.handle_npm_config("abc", os.getcwd())
text = Path(".npmrc").read_text(encoding="utf-8")
assert "_authToken=abc" in text


def test_bump_version(py_package):
for spec in ["1.0.1", "1.0.1.dev1", "1.0.3a4"]:
util.bump_version(spec)
Expand Down

0 comments on commit b93c650

Please sign in to comment.