diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2021-03-15 02:52:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-14 19:52:12 +0100 |
commit | 167b0f46ef946fad3ca13976c3b87598f505e2ea (patch) | |
tree | 8b6a4a47a2a0149899b3eb49b296677c2dba4d36 /models/repo_list.go | |
parent | 164e35ead3c1b9b82d4a23644f6fe96652a747eb (diff) | |
download | gitea-167b0f46ef946fad3ca13976c3b87598f505e2ea.tar.gz gitea-167b0f46ef946fad3ca13976c3b87598f505e2ea.zip |
chore(models): rewrite code format. (#14754)
* chore: rewrite format.
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: Adjacent parameters with the same type should be grouped together
* chore: update format.
Diffstat (limited to 'models/repo_list.go')
-rw-r--r-- | models/repo_list.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/models/repo_list.go b/models/repo_list.go index de3562a2ab..1e06f2511e 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -180,7 +180,7 @@ type SearchRepoOptions struct { LowerNames []string } -//SearchOrderBy is used to sort the result +// SearchOrderBy is used to sort the result type SearchOrderBy string func (s SearchOrderBy) String() string { @@ -207,7 +207,7 @@ const ( // SearchRepositoryCondition creates a query condition according search repository options func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { - var cond = builder.NewCond() + cond := builder.NewCond() if opts.Private { if opts.Actor != nil && !opts.Actor.IsAdmin && opts.Actor.ID != opts.OwnerID { @@ -242,7 +242,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { // Restrict repositories to those the OwnerID owns or contributes to as per opts.Collaborate if opts.OwnerID > 0 { - var accessCond = builder.NewCond() + accessCond := builder.NewCond() if opts.Collaborate != util.OptionalBoolTrue { accessCond = builder.Eq{"owner_id": opts.OwnerID} } @@ -301,7 +301,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { if opts.Keyword != "" { // separate keyword - var subQueryCond = builder.NewCond() + subQueryCond := builder.NewCond() for _, v := range strings.Split(opts.Keyword, ",") { if opts.TopicOnly { subQueryCond = subQueryCond.Or(builder.Eq{"topic.name": strings.ToLower(v)}) @@ -314,9 +314,9 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { Where(subQueryCond). GroupBy("repo_topic.repo_id") - var keywordCond = builder.In("id", subQuery) + keywordCond := builder.In("id", subQuery) if !opts.TopicOnly { - var likes = builder.NewCond() + likes := builder.NewCond() for _, v := range strings.Split(opts.Keyword, ",") { likes = likes.Or(builder.Like{"lower_name", strings.ToLower(v)}) if opts.IncludeDescription { @@ -381,7 +381,6 @@ func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loa count, err := sess. Where(cond). Count(new(Repository)) - if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } @@ -406,7 +405,7 @@ func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loa // accessibleRepositoryCondition takes a user a returns a condition for checking if a repository is accessible func accessibleRepositoryCondition(user *User) builder.Cond { - var cond = builder.NewCond() + cond := builder.NewCond() if user == nil || !user.IsRestricted || user.ID <= 0 { orgVisibilityLimit := []structs.VisibleType{structs.VisibleTypePrivate} |