Skip to content

Commit

Permalink
internal/stdlib: pass -f to git fetch in remoteGoRepo.clone
Browse files Browse the repository at this point in the history
remoteGoRepo.clone inits a repo and then tries to fetch into the
"main" branch of the repo. But if the user's settings are for the
default branch to be called main, main will already exist and the
fetch command will fail. The -f flag will cause the command to do the
fetch even though the branch already exists.

For golang/go#63254
For golang/go#63744

Change-Id: I33f414654088a67eae4bfa70424d0dc6c34903f0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/540635
LUCI-TryBot-Result: Go LUCI <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
kokoro-CI: kokoro <[email protected]>
Run-TryBot: Michael Matloob <[email protected]>
  • Loading branch information
matloob committed Nov 8, 2023
1 parent 4ff3e66 commit a4adca6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/stdlib/gorepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (remoteGoRepo) clone(ctx context.Context, v, directory string) (refName str
if err := cmd.Run(); err != nil {
return "", err
}
cmd = exec.CommandContext(ctx, "git", "fetch", "--depth=1", "--", GoRepoURL, refName+":main")
cmd = exec.CommandContext(ctx, "git", "fetch", "-f", "--depth=1", "--", GoRepoURL, refName+":main")
cmd.Dir = directory
if b, err := cmd.CombinedOutput(); err != nil {
return "", fmt.Errorf("running git fetch: %v: %s", err, b)
Expand Down

0 comments on commit a4adca6

Please sign in to comment.