mirror of
https://github.com/go-gitea/gitea
synced 2024-11-17 15:31:06 +01:00
Fix empty checkout bug (#3419)
This commit is contained in:
parent
36a94da8da
commit
c55a027da3
1 changed files with 6 additions and 6 deletions
|
@ -774,17 +774,17 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) error {
|
||||||
return fmt.Errorf("git clone %s: %v", branch, err)
|
return fmt.Errorf("git clone %s: %v", branch, err)
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
_, err := git.NewCommand("fetch", "origin").RunInDir(localPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("git fetch origin: %v", err)
|
return fmt.Errorf("git fetch origin: %v", err)
|
||||||
}
|
}
|
||||||
if len(branch) > 0 {
|
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 {
|
if err := git.ResetHEAD(localPath, true, "origin/"+branch); err != nil {
|
||||||
return fmt.Errorf("git reset --hard origin/%s: %v", branch, err)
|
return fmt.Errorf("git reset --hard origin/%s: %v", branch, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue