Skip to content

Commit 7564ec3

Browse files
authored
Merge pull request #257 from blink1073/improve-git-clone
2 parents d6a1f76 + 98d6ae4 commit 7564ec3

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")
@@ -532,7 +532,7 @@ def prep_git(ref, branch, repo, auth, username, url):
532532
ref = ref or ""
533533

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

537537
# Handle the ref
538538
if ref.startswith("refs/pull/"):
@@ -543,11 +543,11 @@ def prep_git(ref, branch, repo, auth, username, url):
543543

544544
# Reuse existing branch if possible
545545
if ref:
546-
util.run(f"git fetch origin +{ref}:{ref_alias}")
547-
util.run(f"git fetch origin {ref}")
546+
util.run(f"{util.GIT_FETCH_CMD} +{ref}:{ref_alias}")
547+
util.run(f"{util.GIT_FETCH_CMD} {ref}")
548548
checkout_cmd = f"git checkout -B {branch} {ref_alias}"
549549
else:
550-
util.run(f"git fetch origin {branch}")
550+
util.run(f"{util.GIT_FETCH_CMD} {branch}")
551551
checkout_cmd = f"git checkout {branch}"
552552

553553
if checkout_exists:
@@ -599,7 +599,7 @@ def forwardport_changelog(
599599

600600
# switch to main branch here
601601
branch = branch or util.get_default_branch()
602-
util.run(f"git fetch origin {branch}")
602+
util.run(f"{util.GIT_FETCH_CMD} {branch}")
603603
util.run(f"git checkout {branch}")
604604

605605
# 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(f"{GIT_FETCH_CMD} 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)