summaryrefslogtreecommitdiffstats
path: root/models/branches.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-06-18 01:50:11 +0800
committerGitHub <noreply@github.com>2020-06-17 20:50:11 +0300
commit1645d4a5d8def3cc5451e068aa0a321e028a889b (patch)
tree99e1f29ec2dbb568cfee090ea4a2e49dfca02280 /models/branches.go
parent61cd0ce86601a0bffb625ae27a7b76ee8a15cb36 (diff)
downloadgitea-1645d4a5d8def3cc5451e068aa0a321e028a889b.tar.gz
gitea-1645d4a5d8def3cc5451e068aa0a321e028a889b.zip
Use ID or Where to instead directly use Get when load object from database (#11925)
* Use ID or Where to instead directly use Get when load object from database * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/branches.go')
-rw-r--r--models/branches.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/branches.go b/models/branches.go
index 688e2d7f51..fc3c783b3a 100644
--- a/models/branches.go
+++ b/models/branches.go
@@ -240,8 +240,8 @@ func getProtectedBranchBy(e Engine, repoID int64, branchName string) (*Protected
// GetProtectedBranchByID getting protected branch by ID
func GetProtectedBranchByID(id int64) (*ProtectedBranch, error) {
- rel := &ProtectedBranch{ID: id}
- has, err := x.Get(rel)
+ rel := &ProtectedBranch{}
+ has, err := x.ID(id).Get(rel)
if err != nil {
return nil, err
}
@@ -509,9 +509,9 @@ func (repo *Repository) GetDeletedBranches() ([]*DeletedBranch, error) {
}
// GetDeletedBranchByID get a deleted branch by its ID
-func (repo *Repository) GetDeletedBranchByID(ID int64) (*DeletedBranch, error) {
- deletedBranch := &DeletedBranch{ID: ID}
- has, err := x.Get(deletedBranch)
+func (repo *Repository) GetDeletedBranchByID(id int64) (*DeletedBranch, error) {
+ deletedBranch := &DeletedBranch{}
+ has, err := x.ID(id).Get(deletedBranch)
if err != nil {
return nil, err
}