mirror of
https://github.com/gogs/gogs.git
synced 2025-12-24 01:00:00 +01:00
repo: fix unable to propose pull request from secondary fork (#4324)
This commit is contained in:
2
gogs.go
2
gogs.go
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.10.27.0323"
|
const APP_VER = "0.10.28.0323"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ func SetEngine() (err error) {
|
|||||||
// WARNING: for serv command, MUST remove the output to os.stdout,
|
// WARNING: for serv command, MUST remove the output to os.stdout,
|
||||||
// so use log file to instead print to stdout.
|
// so use log file to instead print to stdout.
|
||||||
sec := setting.Cfg.Section("log.xorm")
|
sec := setting.Cfg.Section("log.xorm")
|
||||||
fmt.Println(sec.Key("ROTATE_DAILY").MustBool(true))
|
|
||||||
logger, err := log.NewFileWriter(path.Join(setting.LogRootPath, "xorm.log"),
|
logger, err := log.NewFileWriter(path.Join(setting.LogRootPath, "xorm.log"),
|
||||||
log.FileRotationConfig{
|
log.FileRotationConfig{
|
||||||
Rotate: sec.Key("ROTATE").MustBool(true),
|
Rotate: sec.Key("ROTATE").MustBool(true),
|
||||||
|
|||||||
@@ -236,6 +236,18 @@ func (repo *Repository) loadAttributes(e Engine) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if repo.IsFork && repo.BaseRepo == nil {
|
||||||
|
repo.BaseRepo, err = getRepositoryByID(e, repo.ForkID)
|
||||||
|
if err != nil {
|
||||||
|
if errors.IsRepoNotExist(err) {
|
||||||
|
repo.IsFork = false
|
||||||
|
repo.ForkID = 0
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("getRepositoryByID [%d]: %v", repo.ForkID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,15 +430,6 @@ func (repo *Repository) GetMirror() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) GetBaseRepo() (err error) {
|
|
||||||
if !repo.IsFork {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
repo.BaseRepo, err = GetRepositoryByID(repo.ForkID)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repo *Repository) repoPath(e Engine) string {
|
func (repo *Repository) repoPath(e Engine) string {
|
||||||
return RepoPath(repo.mustOwner(e).Name, repo.Name)
|
return RepoPath(repo.mustOwner(e).Name, repo.Name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,22 +108,6 @@ func (r *Repository) PullRequestURL(baseBranch, headBranch string) string {
|
|||||||
return fmt.Sprintf("%s/compare/%s...%s:%s", repoLink, baseBranch, r.Owner.Name, headBranch)
|
return fmt.Sprintf("%s/compare/%s...%s:%s", repoLink, baseBranch, r.Owner.Name, headBranch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
|
|
||||||
// Non-fork repository will not return error in this method.
|
|
||||||
if err := repo.GetBaseRepo(); err != nil {
|
|
||||||
if errors.IsRepoNotExist(err) {
|
|
||||||
repo.IsFork = false
|
|
||||||
repo.ForkID = 0
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.Handle(500, "GetBaseRepo", err)
|
|
||||||
return
|
|
||||||
} else if err = repo.BaseRepo.GetOwner(); err != nil {
|
|
||||||
ctx.Handle(500, "BaseRepo.GetOwner", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// composeGoGetImport returns go-get-import meta content.
|
// composeGoGetImport returns go-get-import meta content.
|
||||||
func composeGoGetImport(owner, repo string) string {
|
func composeGoGetImport(owner, repo string) string {
|
||||||
return path.Join(setting.Domain, setting.AppSubUrl, owner, repo)
|
return path.Join(setting.Domain, setting.AppSubUrl, owner, repo)
|
||||||
@@ -410,23 +394,24 @@ func RepoRef() macaron.Handler {
|
|||||||
ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag
|
ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag
|
||||||
ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit
|
ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit
|
||||||
|
|
||||||
if ctx.Repo.Repository.IsFork {
|
|
||||||
RetrieveBaseRepo(ctx, ctx.Repo.Repository)
|
|
||||||
if ctx.Written() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// People who have push access or have fored repository can propose a new pull request.
|
// People who have push access or have fored repository can propose a new pull request.
|
||||||
if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
|
if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
|
||||||
// Pull request is allowed if this is a fork repository
|
// Pull request is allowed if this is a fork repository
|
||||||
// and base repository accepts pull requests.
|
// and base repository accepts pull requests.
|
||||||
if ctx.Repo.Repository.BaseRepo != nil {
|
if ctx.Repo.Repository.BaseRepo != nil {
|
||||||
if ctx.Repo.Repository.BaseRepo.AllowsPulls() {
|
if ctx.Repo.Repository.BaseRepo.AllowsPulls() {
|
||||||
ctx.Data["BaseRepo"] = ctx.Repo.Repository.BaseRepo
|
|
||||||
ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository.BaseRepo
|
|
||||||
ctx.Repo.PullRequest.Allowed = true
|
ctx.Repo.PullRequest.Allowed = true
|
||||||
ctx.Repo.PullRequest.HeadInfo = ctx.Repo.Owner.Name + ":" + ctx.Repo.BranchName
|
// In-repository pull requests has higher priority than cross-repository if user is viewing
|
||||||
|
// base repository and 1) has write access to it 2) has forked it.
|
||||||
|
if ctx.Repo.IsWriter() {
|
||||||
|
ctx.Data["BaseRepo"] = ctx.Repo.Repository.BaseRepo
|
||||||
|
ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository.BaseRepo
|
||||||
|
ctx.Repo.PullRequest.HeadInfo = ctx.Repo.Owner.Name + ":" + ctx.Repo.BranchName
|
||||||
|
} else {
|
||||||
|
ctx.Data["BaseRepo"] = ctx.Repo.Repository
|
||||||
|
ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository
|
||||||
|
ctx.Repo.PullRequest.HeadInfo = ctx.User.Name + ":" + ctx.Repo.BranchName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Or, this is repository accepts pull requests between branches.
|
// Or, this is repository accepts pull requests between branches.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.10.27.0323
|
0.10.28.0323
|
||||||
Reference in New Issue
Block a user