Skip to content

Commit

Permalink
fix tests and add a cache check on LoadBaseRepo
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Oct 18, 2019
1 parent 8a3937f commit 9ad2d76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 0 additions & 3 deletions models/fixtures/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
index: 2
head_repo_id: 1
base_repo_id: 1
head_user_name: user1
head_branch: branch1
base_branch: master
merge_base: 1234567890abcdef
Expand All @@ -21,7 +20,6 @@
index: 3
head_repo_id: 1
base_repo_id: 1
head_user_name: user1
head_branch: branch2
base_branch: master
merge_base: fedcba9876543210
Expand All @@ -35,7 +33,6 @@
index: 1
head_repo_id: 11
base_repo_id: 10
head_user_name: user13
head_branch: branch2
base_branch: master
merge_base: 0abcb056019adb83
Expand Down
4 changes: 4 additions & 0 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (pr *PullRequest) LoadAttributes() error {
// LoadBaseRepo loads pull request base repository from database
func (pr *PullRequest) LoadBaseRepo() error {
if pr.BaseRepo == nil {
if pr.HeadRepoID == pr.BaseRepoID && pr.HeadRepo != nil {
pr.BaseRepo = pr.HeadRepo
return nil
}
var repo Repository
if has, err := x.ID(pr.BaseRepoID).Get(&repo); err != nil {
return err
Expand Down

0 comments on commit 9ad2d76

Please sign in to comment.