mirror of https://github.com/go-gitea/gitea.git
This commit is contained in:
parent
912ce27421
commit
f5727d83dd
|
@ -420,7 +420,7 @@ func (pr *PullRequest) apiFormat(e Engine) *api.PullRequest {
|
|||
err error
|
||||
)
|
||||
if err = pr.Issue.loadRepo(e); err != nil {
|
||||
log.Error("loadRepo[%d]: %v", pr.ID, err)
|
||||
log.Error("pr.Issue.loadRepo[%d]: %v", pr.ID, err)
|
||||
return nil
|
||||
}
|
||||
apiIssue := pr.Issue.apiFormat(e)
|
||||
|
@ -431,19 +431,14 @@ func (pr *PullRequest) apiFormat(e Engine) *api.PullRequest {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
if pr.HeadRepo == nil {
|
||||
if pr.HeadRepoID != 0 && pr.HeadRepo == nil {
|
||||
pr.HeadRepo, err = getRepositoryByID(e, pr.HeadRepoID)
|
||||
if err != nil {
|
||||
if err != nil && !IsErrRepoNotExist(err) {
|
||||
log.Error("GetRepositoryById[%d]: %v", pr.ID, err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if err = pr.Issue.loadRepo(e); err != nil {
|
||||
log.Error("pr.Issue.loadRepo[%d]: %v", pr.ID, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
apiPullRequest := &api.PullRequest{
|
||||
ID: pr.ID,
|
||||
URL: pr.Issue.HTMLURL(),
|
||||
|
@ -495,6 +490,7 @@ func (pr *PullRequest) apiFormat(e Engine) *api.PullRequest {
|
|||
apiPullRequest.Base = apiBaseBranchInfo
|
||||
}
|
||||
|
||||
if pr.HeadRepo != nil {
|
||||
headBranch, err = pr.HeadRepo.GetBranch(pr.HeadBranch)
|
||||
if err != nil {
|
||||
if git.IsErrBranchNotExist(err) {
|
||||
|
@ -523,6 +519,13 @@ func (pr *PullRequest) apiFormat(e Engine) *api.PullRequest {
|
|||
}
|
||||
apiPullRequest.Head = apiHeadBranchInfo
|
||||
}
|
||||
} else {
|
||||
apiPullRequest.Head = &api.PRBranchInfo{
|
||||
Name: pr.HeadBranch,
|
||||
Ref: fmt.Sprintf("refs/pull/%d/head", pr.Index),
|
||||
RepoID: -1,
|
||||
}
|
||||
}
|
||||
|
||||
if pr.Status != PullRequestStatusChecking {
|
||||
mergeable := !(pr.Status == PullRequestStatusConflict || pr.Status == PullRequestStatusError) && !pr.IsWorkInProgress()
|
||||
|
|
Loading…
Reference in New Issue