Skip to content

Commit a55b5cd

Browse files
authored
Merge branch 'master' into fix-go-gitea#6716
2 parents 95b3b92 + 4c34bc1 commit a55b5cd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

models/error.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,24 @@ func (err ErrPullRequestAlreadyExists) Error() string {
10911091
err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
10921092
}
10931093

1094+
// ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error
1095+
type ErrPullRequestHeadRepoMissing struct {
1096+
ID int64
1097+
HeadRepoID int64
1098+
}
1099+
1100+
// IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.
1101+
func IsErrErrPullRequestHeadRepoMissing(err error) bool {
1102+
_, ok := err.(ErrPullRequestHeadRepoMissing)
1103+
return ok
1104+
}
1105+
1106+
// Error does pretty-printing :D
1107+
func (err ErrPullRequestHeadRepoMissing) Error() string {
1108+
return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]",
1109+
err.ID, err.HeadRepoID)
1110+
}
1111+
10941112
// ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
10951113
type ErrInvalidMergeStyle struct {
10961114
ID int64

models/pull.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ func (pr *PullRequest) GetLastCommitStatus() (status *CommitStatus, err error) {
299299
return nil, err
300300
}
301301

302+
if pr.HeadRepo == nil {
303+
return nil, ErrPullRequestHeadRepoMissing{pr.ID, pr.HeadRepoID}
304+
}
305+
302306
headGitRepo, err := git.OpenRepository(pr.HeadRepo.RepoPath())
303307
if err != nil {
304308
return nil, err

routers/repo/issue.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
223223
return
224224
}
225225

226-
if isPullOption == util.OptionalBoolTrue {
226+
if issues[i].IsPull {
227+
if err := issues[i].LoadPullRequest(); err != nil {
228+
ctx.ServerError("LoadPullRequest", err)
229+
return
230+
}
231+
227232
commitStatus[issues[i].PullRequest.ID], _ = issues[i].PullRequest.GetLastCommitStatus()
228233
}
229234
}

0 commit comments

Comments
 (0)