Skip to content

Commit

Permalink
Fix empty checkout bug (go-gitea#3419)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig authored and lafriks committed Jan 28, 2018
1 parent 36a94da commit c55a027
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,17 +774,17 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) error {
return fmt.Errorf("git clone %s: %v", branch, err)
}
} else {
if err := git.Checkout(localPath, git.CheckoutOptions{
Branch: branch,
}); err != nil {
return fmt.Errorf("git checkout %s: %v", branch, err)
}

_, err := git.NewCommand("fetch", "origin").RunInDir(localPath)
if err != nil {
return fmt.Errorf("git fetch origin: %v", err)
}
if len(branch) > 0 {
if err := git.Checkout(localPath, git.CheckoutOptions{
Branch: branch,
}); err != nil {
return fmt.Errorf("git checkout %s: %v", branch, err)
}

if err := git.ResetHEAD(localPath, true, "origin/"+branch); err != nil {
return fmt.Errorf("git reset --hard origin/%s: %v", branch, err)
}
Expand Down

0 comments on commit c55a027

Please sign in to comment.