summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-10 22:59:13 -0400
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-06-10 21:59:13 -0500
commite0a63a20e04ead19e87c27c1e209d1d431fc51ba (patch)
tree229744dab9fa9435cdd1b9fc3768e22c5e005913 /models/repo.go
parent96b4780727b49a2c30c640a73751566f60ffc2af (diff)
downloadgitea-e0a63a20e04ead19e87c27c1e209d1d431fc51ba.tar.gz
gitea-e0a63a20e04ead19e87c27c1e209d1d431fc51ba.zip
Fix errors caused by force push (#1927)
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go
index f92f753b92..8fda3c674d 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -700,12 +700,13 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) error {
}); err != nil {
return fmt.Errorf("git checkout %s: %v", branch, err)
}
- if err := git.Pull(localPath, git.PullRemoteOptions{
- Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
- Remote: "origin",
- Branch: branch,
- }); err != nil {
- return fmt.Errorf("git pull origin %s: %v", branch, err)
+
+ _, err := git.NewCommand("fetch", "origin").RunInDir(localPath)
+ if err != nil {
+ return fmt.Errorf("git fetch origin: %v", err)
+ }
+ if err := git.ResetHEAD(localPath, true, "origin/"+branch); err != nil {
+ return fmt.Errorf("git reset --hard origin/%s: %v", branch, err)
}
}
return nil