Skip to content

Commit 9ad2d76

Browse files
committed
fix tests and add a cache check on LoadBaseRepo
1 parent 8a3937f commit 9ad2d76

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

models/fixtures/pull_request.yml

-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
index: 2
77
head_repo_id: 1
88
base_repo_id: 1
9-
head_user_name: user1
109
head_branch: branch1
1110
base_branch: master
1211
merge_base: 1234567890abcdef
@@ -21,7 +20,6 @@
2120
index: 3
2221
head_repo_id: 1
2322
base_repo_id: 1
24-
head_user_name: user1
2523
head_branch: branch2
2624
base_branch: master
2725
merge_base: fedcba9876543210
@@ -35,7 +33,6 @@
3533
index: 1
3634
head_repo_id: 11
3735
base_repo_id: 10
38-
head_user_name: user13
3936
head_branch: branch2
4037
base_branch: master
4138
merge_base: 0abcb056019adb83

models/pull.go

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ func (pr *PullRequest) LoadAttributes() error {
110110
// LoadBaseRepo loads pull request base repository from database
111111
func (pr *PullRequest) LoadBaseRepo() error {
112112
if pr.BaseRepo == nil {
113+
if pr.HeadRepoID == pr.BaseRepoID && pr.HeadRepo != nil {
114+
pr.BaseRepo = pr.HeadRepo
115+
return nil
116+
}
113117
var repo Repository
114118
if has, err := x.ID(pr.BaseRepoID).Get(&repo); err != nil {
115119
return err

0 commit comments

Comments
 (0)