aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-04 16:53:03 -0500
committerUnknwon <u@gogs.io>2016-03-04 16:53:03 -0500
commite2d370f0da8e3f8092240b745347d863c319885f (patch)
tree3a3f4ed0123227a7f2b5d0b7e8df39288ec6235b /models
parent4cb8bf1b75fe0361ca09f8b510e014c7e25ab3ef (diff)
downloadgitea-e2d370f0da8e3f8092240b745347d863c319885f.tar.gz
gitea-e2d370f0da8e3f8092240b745347d863c319885f.zip
#1597 fix pull request remote head can't update with force push
Diffstat (limited to 'models')
-rw-r--r--models/issue.go2
-rw-r--r--models/pull.go7
2 files changed, 7 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go
index 4c33bc6b26..a11b9b3f0c 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -301,7 +301,7 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64,
// So we have to get all needed labels first.
labels := make([]*Label, 0, len(labelIDs))
if err = e.In("id", labelIDs).Find(&labels); err != nil {
- return fmt.Errorf("Find all labels: %v", err)
+ return fmt.Errorf("find all labels: %v", err)
}
for _, label := range labels {
diff --git a/models/pull.go b/models/pull.go
index 77484b9562..8103d71ea1 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -502,7 +502,12 @@ func (pr *PullRequest) PushToBaseRepo() (err error) {
// Make sure to remove the remote even if the push fails
defer headGitRepo.RemoveRemote(tmpRemoteName)
- if err = git.Push(headRepoPath, tmpRemoteName, fmt.Sprintf("%s:refs/pull/%d/head", pr.HeadBranch, pr.Index)); err != nil {
+ headFile := fmt.Sprintf("refs/pull/%d/head", pr.Index)
+
+ // Remove head in case there is a conflict.
+ os.Remove(path.Join(pr.BaseRepo.RepoPath(), headFile))
+
+ if err = git.Push(headRepoPath, tmpRemoteName, fmt.Sprintf("%s:%s", pr.HeadBranch, headFile)); err != nil {
return fmt.Errorf("Push: %v", err)
}