Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3c6830de
Commit
3c6830de
authored
Oct 08, 2021
by
Matt Kasa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an exact_name param to the GroupPackagesFinder
Relates to
https://gitlab.com/gitlab-org/gitlab/-/issues/333790
parent
664586f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
app/finders/concerns/packages/finder_helper.rb
app/finders/concerns/packages/finder_helper.rb
+6
-0
app/finders/packages/group_packages_finder.rb
app/finders/packages/group_packages_finder.rb
+2
-2
spec/finders/packages/group_packages_finder_spec.rb
spec/finders/packages/group_packages_finder_spec.rb
+13
-0
No files found.
app/finders/concerns/packages/finder_helper.rb
View file @
3c6830de
...
...
@@ -54,6 +54,12 @@ module Packages
packages
.
search_by_name
(
params
[
:package_name
])
end
def
filter_by_exact_package_name
(
packages
)
return
packages
unless
params
[
:package_name
].
present?
packages
.
with_name
(
params
[
:package_name
])
end
def
filter_by_package_version
(
packages
)
return
packages
unless
params
[
:package_version
].
present?
...
...
app/finders/packages/group_packages_finder.rb
View file @
3c6830de
...
...
@@ -4,7 +4,7 @@ module Packages
class
GroupPackagesFinder
include
::
Packages
::
FinderHelper
def
initialize
(
current_user
,
group
,
params
=
{
exclude_subgroups:
false
,
order_by:
'created_at'
,
sort:
'asc'
})
def
initialize
(
current_user
,
group
,
params
=
{
exclude_subgroups:
false
,
exact_name:
false
,
order_by:
'created_at'
,
sort:
'asc'
})
@current_user
=
current_user
@group
=
group
@params
=
params
...
...
@@ -30,7 +30,7 @@ module Packages
packages
=
filter_with_version
(
packages
)
packages
=
filter_by_package_type
(
packages
)
packages
=
filter_by_package_name
(
packages
)
packages
=
(
params
[
:exact_name
]
?
filter_by_exact_package_name
(
packages
)
:
filter_by_package_name
(
packages
)
)
packages
=
filter_by_package_version
(
packages
)
installable_only
?
packages
.
installable
:
filter_by_status
(
packages
)
end
...
...
spec/finders/packages/group_packages_finder_spec.rb
View file @
3c6830de
...
...
@@ -147,6 +147,19 @@ RSpec.describe Packages::GroupPackagesFinder do
end
end
context
'with exact package_name'
do
let_it_be
(
:named_package
)
{
create
(
:maven_package
,
project:
project
,
name:
'maven'
)
}
let_it_be
(
:other_package
)
{
create
(
:maven_package
,
project:
project
,
name:
'maventoo'
)
}
let
(
:params
)
{
{
exact_name:
true
,
package_name:
package_name
}
}
context
'as complete name'
do
let
(
:package_name
)
{
'maven'
}
it
{
is_expected
.
to
match_array
([
named_package
])
}
end
end
it_behaves_like
'concerning versionless param'
it_behaves_like
'concerning package statuses'
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment