mirror of
https://github.com/go-gitea/gitea
synced 2024-11-17 09:09:28 +01:00
Minor fix for #2524
This commit is contained in:
parent
f6c98465c7
commit
b7f3d94cd0
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
|||||||
|
|
||||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current version: 0.8.39
|
##### Current version: 0.8.40
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
2
gogs.go
2
gogs.go
@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.8.39.0219"
|
const APP_VER = "0.8.40.0219"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/process"
|
"github.com/gogits/gogs/modules/process"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PullRequestType int
|
type PullRequestType int
|
||||||
@ -483,35 +482,28 @@ func (pr *PullRequest) UpdatePatch() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PushToBaseRepo pushes commits from branches of head repository to
|
||||||
|
// corresponding branches of base repository.
|
||||||
|
// FIXME: could fail after user force push head repo, should we always force push here?
|
||||||
|
// FIXME: Only push branches that are actually updates?
|
||||||
func (pr *PullRequest) PushToBaseRepo() (err error) {
|
func (pr *PullRequest) PushToBaseRepo() (err error) {
|
||||||
log.Trace("PushToBase[%d]: pushing commits to base repo refs/pull/%d/head", pr.ID, pr.ID)
|
log.Trace("PushToBaseRepo[%[1]d]: pushing commits to base repo 'refs/pull/%[1]d/head'", pr.ID)
|
||||||
|
|
||||||
branch := pr.HeadBranch
|
headRepoPath := pr.HeadRepo.RepoPath()
|
||||||
|
headGitRepo, err := git.OpenRepository(headRepoPath)
|
||||||
if err = pr.BaseRepo.GetOwner(); err != nil {
|
|
||||||
return fmt.Errorf("Could not get base repo owner data: %v", err)
|
|
||||||
} else if err = pr.HeadRepo.GetOwner(); err != nil {
|
|
||||||
return fmt.Errorf("Could not get head repo owner data: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
headRepoPath := RepoPath(pr.HeadRepo.Owner.Name, pr.HeadRepo.Name)
|
|
||||||
|
|
||||||
prIdStr := strconv.FormatInt(pr.ID, 10)
|
|
||||||
tmpRemoteName := "tmp-pull-" + branch + "-" + prIdStr
|
|
||||||
repo, err := git.OpenRepository(headRepoPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to open head repository: %v", err)
|
return fmt.Errorf("OpenRepository: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = repo.AddRemote(tmpRemoteName, RepoPath(pr.BaseRepo.Owner.Name, pr.BaseRepo.Name), false); err != nil {
|
tmpRemoteName := fmt.Sprintf("tmp-pull-%d", pr.ID)
|
||||||
return fmt.Errorf("Unable to add remote to head repository: %v", err)
|
if err = headGitRepo.AddRemote(tmpRemoteName, pr.BaseRepo.RepoPath(), false); err != nil {
|
||||||
|
return fmt.Errorf("headGitRepo.AddRemote: %v", err)
|
||||||
}
|
}
|
||||||
// Make sure to remove the remote even if the push fails
|
// Make sure to remove the remote even if the push fails
|
||||||
defer repo.RemoveRemote(tmpRemoteName)
|
defer headGitRepo.RemoveRemote(tmpRemoteName)
|
||||||
|
|
||||||
pushRef := branch+":"+"refs/pull/"+prIdStr+"/head"
|
if err = git.Push(headRepoPath, tmpRemoteName, fmt.Sprintf("%s:refs/pull/%d/head", pr.HeadBranch, pr.Index)); err != nil {
|
||||||
if err = git.Push(headRepoPath, tmpRemoteName, pushRef); err != nil {
|
return fmt.Errorf("Push: %v", err)
|
||||||
return fmt.Errorf("Error pushing: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -1 +1 @@
|
|||||||
0.8.39.0219
|
0.8.40.0219
|
Loading…
Reference in New Issue
Block a user