Skip to content

Commit e476a10

Browse files
committed
Use a more efficient fetch
1 parent 0082d05 commit e476a10

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

jupyter_releaser/lib.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def make_changelog_pr(auth, branch, repo, title, commit_message, body, dry_run=F
153153
dirty = util.run("git --no-pager diff --stat") != ""
154154
if dirty:
155155
util.run("git stash")
156-
util.run(f"git fetch origin {branch}")
156+
util.run(f"{util.GIT_FETCH_CMD} {branch}")
157157
util.run(f"git checkout -b {pr_branch} origin/{branch}")
158158
if dirty:
159159
util.run("git stash apply")
@@ -530,7 +530,7 @@ def prep_git(ref, branch, repo, auth, username, url):
530530
ref = ref or ""
531531

532532
# Make sure we have *all* tags
533-
util.run("git fetch origin --tags --force --quiet")
533+
util.run(f"{util.GIT_FETCH_CMD} --tags --force ")
534534

535535
# Handle the ref
536536
if ref.startswith("refs/pull/"):
@@ -541,11 +541,11 @@ def prep_git(ref, branch, repo, auth, username, url):
541541

542542
# Reuse existing branch if possible
543543
if ref:
544-
util.run(f"git fetch origin +{ref}:{ref_alias}")
545-
util.run(f"git fetch origin {ref}")
544+
util.run(f"{util.GIT_FETCH_CMD} +{ref}:{ref_alias}")
545+
util.run(f"{util.GIT_FETCH_CMD} {ref}")
546546
checkout_cmd = f"git checkout -B {branch} {ref_alias}"
547547
else:
548-
util.run(f"git fetch origin {branch}")
548+
util.run(f"{util.GIT_FETCH_CMD} {branch}")
549549
checkout_cmd = f"git checkout {branch}"
550550

551551
if checkout_exists:
@@ -597,7 +597,7 @@ def forwardport_changelog(
597597

598598
# switch to main branch here
599599
branch = branch or util.get_default_branch()
600-
util.run(f"git fetch origin {branch}")
600+
util.run(f" {branch}")
601601
util.run(f"git checkout {branch}")
602602

603603
# Bail if the tag has been merged to the branch

jupyter_releaser/tests/test_cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from jupyter_releaser.tests.util import REPO_DATA
2525
from jupyter_releaser.tests.util import VERSION_SPEC
2626
from jupyter_releaser.util import bump_version
27+
from jupyter_releaser.util import GIT_FETCH_CMD
2728
from jupyter_releaser.util import normalize_path
2829
from jupyter_releaser.util import run
2930

@@ -107,9 +108,9 @@ def test_prep_git_full(py_package, tmp_path, mocker, runner):
107108
call('git config --global user.name "GitHub Action"'),
108109
call("git init .jupyter_releaser_checkout"),
109110
call("git remote add origin https://snuffy:[email protected]/baz/bar.git"),
110-
call("git fetch origin --tags --force --quiet"),
111-
call("git fetch origin +refs/pull/42:refs/pull/42"),
112-
call("git fetch origin refs/pull/42"),
111+
call(f"{GIT_FETCH_CMD} --tags --force"),
112+
call(f"{GIT_FETCH_CMD} +refs/pull/42:refs/pull/42"),
113+
call(" refs/pull/42"),
113114
call("git checkout -B foo refs/pull/42"),
114115
]
115116
)

jupyter_releaser/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
SCHEMA = files("jupyter_releaser").joinpath("schema.json").read_text()
4646
SCHEMA = json.loads(SCHEMA)
4747

48+
GIT_FETCH_CMD = "git fetch origin --filter=blob:none --quiet"
49+
4850

4951
def run(cmd, **kwargs):
5052
"""Run a command as a subprocess and get the output as a string"""

0 commit comments

Comments
 (0)