Skip to content

Commit c55a027

Browse files
ethantkoeniglafriks
authored andcommitted
Fix empty checkout bug (#3419)
1 parent 36a94da commit c55a027

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

models/repo.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,17 +774,17 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) error {
774774
return fmt.Errorf("git clone %s: %v", branch, err)
775775
}
776776
} else {
777-
if err := git.Checkout(localPath, git.CheckoutOptions{
778-
Branch: branch,
779-
}); err != nil {
780-
return fmt.Errorf("git checkout %s: %v", branch, err)
781-
}
782-
783777
_, err := git.NewCommand("fetch", "origin").RunInDir(localPath)
784778
if err != nil {
785779
return fmt.Errorf("git fetch origin: %v", err)
786780
}
787781
if len(branch) > 0 {
782+
if err := git.Checkout(localPath, git.CheckoutOptions{
783+
Branch: branch,
784+
}); err != nil {
785+
return fmt.Errorf("git checkout %s: %v", branch, err)
786+
}
787+
788788
if err := git.ResetHEAD(localPath, true, "origin/"+branch); err != nil {
789789
return fmt.Errorf("git reset --hard origin/%s: %v", branch, err)
790790
}

0 commit comments

Comments
 (0)