Skip to content

Commit 7a31538

Browse files
authored
Fetch only default branch when syncing the fork (#938)
* Fetch only default branch when syncing the fork The default branch is the only branch required from the upstream repo for syncing Scala Steward's fork. Working on large repos with many branches will be a lot faster with this change. * Update tests
1 parent 764ee6a commit 7a31538

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

modules/core/src/main/scala/org/scalasteward/core/git/GitAlg.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ object GitAlg {
171171
branch = defaultBranch.name
172172
remoteBranch = s"$remote/$branch"
173173
_ <- exec(Nel.of("remote", "add", remote, upstreamUrl.toString), repoDir)
174-
_ <- exec(Nel.of("fetch", remote), repoDir)
174+
_ <- exec(Nel.of("fetch", remote, branch), repoDir)
175175
_ <- exec(Nel.of("checkout", "-B", branch, "--track", remoteBranch), repoDir)
176176
_ <- exec(Nel.of("merge", remoteBranch), repoDir)
177177
_ <- push(repo, defaultBranch)

modules/core/src/test/scala/org/scalasteward/core/git/GitAlgTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class GitAlgTest extends AnyFunSuite with Matchers {
8989
"upstream",
9090
"http://github.com/fthomas/datapackage"
9191
),
92-
List(askPass, repoDir, "git", "fetch", "upstream"),
92+
List(askPass, repoDir, "git", "fetch", "upstream", "master"),
9393
List(askPass, repoDir, "git", "checkout", "-B", "master", "--track", "upstream/master"),
9494
List(askPass, repoDir, "git", "merge", "upstream/master"),
9595
List(askPass, repoDir, "git", "push", "--force", "--set-upstream", "origin", "master")

modules/core/src/test/scala/org/scalasteward/core/github/GitHubRepoAlgTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class GitHubRepoAlgTest extends AnyFunSuite with Matchers {
7474
"upstream",
7575
s"https://${config.vcsLogin}@github.com/fthomas/datapackage"
7676
),
77-
List(askPass, repoDir, "git", "fetch", "upstream"),
77+
List(askPass, repoDir, "git", "fetch", "upstream", "master"),
7878
List(askPass, repoDir, "git", "checkout", "-B", "master", "--track", "upstream/master"),
7979
List(askPass, repoDir, "git", "merge", "upstream/master"),
8080
List(askPass, repoDir, "git", "push", "--force", "--set-upstream", "origin", "master")

0 commit comments

Comments
 (0)