]> source.dussan.org Git - gitea.git/commitdiff
Fix errors caused by force push (#1927)
authorEthan Koenig <etk39@cornell.edu>
Sun, 11 Jun 2017 02:59:13 +0000 (22:59 -0400)
committerBo-Yi Wu <appleboy.tw@gmail.com>
Sun, 11 Jun 2017 02:59:13 +0000 (21:59 -0500)
models/repo.go

index f92f753b9223b2815d0d52145e1eee3b43f80b5a..8fda3c674d5d3c606d8ed0ed8e4fce2c69e19ee4 100644 (file)
@@ -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