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
f02101b8
Commit
f02101b8
authored
Apr 12, 2021
by
Matija Čupić
Committed by
Markus Koller
Apr 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add branch names field to repository type
parent
fb551ba2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
0 deletions
+64
-0
app/graphql/resolvers/repository_branch_names_resolver.rb
app/graphql/resolvers/repository_branch_names_resolver.rb
+17
-0
app/graphql/types/repository_type.rb
app/graphql/types/repository_type.rb
+3
-0
changelogs/unreleased/mc-backstage-graphql-list-available-branches.yml
...released/mc-backstage-graphql-list-available-branches.yml
+5
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
spec/graphql/resolvers/repository_branch_names_resolver_spec.rb
...raphql/resolvers/repository_branch_names_resolver_spec.rb
+36
-0
spec/graphql/types/repository_type_spec.rb
spec/graphql/types/repository_type_spec.rb
+2
-0
No files found.
app/graphql/resolvers/repository_branch_names_resolver.rb
0 → 100644
View file @
f02101b8
# frozen_string_literal: true
module
Resolvers
class
RepositoryBranchNamesResolver
<
BaseResolver
type
::
GraphQL
::
STRING_TYPE
,
null:
false
calls_gitaly!
argument
:search_pattern
,
GraphQL
::
STRING_TYPE
,
required:
true
,
description:
'The pattern to search for branch names by.'
def
resolve
(
search_pattern
:)
Repositories
::
BranchNamesFinder
.
new
(
object
,
search:
search_pattern
).
execute
end
end
end
app/graphql/types/repository_type.rb
View file @
f02101b8
...
...
@@ -16,5 +16,8 @@ module Types
description:
'Tree of the repository.'
field
:blobs
,
Types
::
Tree
::
BlobType
.
connection_type
,
null:
true
,
resolver:
Resolvers
::
BlobsResolver
,
calls_gitaly:
true
,
description:
'Blobs contained within the repository'
field
:branch_names
,
[
GraphQL
::
STRING_TYPE
],
null:
true
,
calls_gitaly:
true
,
complexity:
170
,
description:
'Names of branches available in this repository that match the search pattern.'
,
resolver:
Resolvers
::
RepositoryBranchNamesResolver
end
end
changelogs/unreleased/mc-backstage-graphql-list-available-branches.yml
0 → 100644
View file @
f02101b8
---
title
:
Add branch names field to repository GraphQL type.
merge_request
:
55074
author
:
type
:
changed
doc/api/graphql/reference/index.md
View file @
f02101b8
...
...
@@ -5444,6 +5444,7 @@ Autogenerated return type of RepositionImageDiffNote.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`blobs`
|
[
`BlobConnection`
](
#blobconnection
)
| Blobs contained within the repository. |
|
`branchNames`
|
[
`[String!]`
](
#string
)
| Names of branches available in this repository that match the search pattern. |
|
`empty`
|
[
`Boolean!`
](
#boolean
)
| Indicates repository has no visible content. |
|
`exists`
|
[
`Boolean!`
](
#boolean
)
| Indicates a corresponding Git repository exists on disk. |
|
`rootRef`
|
[
`String`
](
#string
)
| Default branch of the repository. |
...
...
spec/graphql/resolvers/repository_branch_names_resolver_spec.rb
0 → 100644
View file @
f02101b8
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Resolvers
::
RepositoryBranchNamesResolver
do
include
GraphqlHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
describe
'#resolve'
do
subject
(
:resolve_branch_names
)
do
resolve
(
described_class
,
obj:
project
.
repository
,
args:
{
search_pattern:
pattern
},
ctx:
{
current_user:
project
.
creator
}
)
end
context
'with empty search pattern'
do
let
(
:pattern
)
{
''
}
it
'returns nil'
do
expect
(
resolve_branch_names
).
to
eq
(
nil
)
end
end
context
'with a valid search pattern'
do
let
(
:pattern
)
{
'mas*'
}
it
'returns matching branches'
do
expect
(
resolve_branch_names
).
to
match_array
([
'master'
])
end
end
end
end
spec/graphql/types/repository_type_spec.rb
View file @
f02101b8
...
...
@@ -14,4 +14,6 @@ RSpec.describe GitlabSchema.types['Repository'] do
specify
{
expect
(
described_class
).
to
have_graphql_field
(
:exists
,
calls_gitaly?:
true
,
complexity:
2
)
}
specify
{
expect
(
described_class
).
to
have_graphql_field
(
:blobs
)
}
specify
{
expect
(
described_class
).
to
have_graphql_field
(
:branch_names
,
calls_gitaly?:
true
,
complexity:
170
)
}
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