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
c6519577
Commit
c6519577
authored
Mar 11, 2020
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose first_contribution for merge request API
Only for getting a single merge request
parent
61cdcb8f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
0 deletions
+33
-0
changelogs/unreleased/24742-1st-contribution.yml
changelogs/unreleased/24742-1st-contribution.yml
+5
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+1
-0
lib/api/entities/merge_request.rb
lib/api/entities/merge_request.rb
+10
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+16
-0
No files found.
changelogs/unreleased/24742-1st-contribution.yml
0 → 100644
View file @
c6519577
---
title
:
Add first_contribution to single merge request API
merge_request
:
26926
author
:
type
:
added
doc/api/merge_requests.md
View file @
c6519577
...
...
@@ -668,6 +668,7 @@ dependent on the `merge_status`. It'll return `false` unless `merge_status` is
},
"diverged_commits_count"
:
2
,
"rebase_in_progress"
:
false
,
"first_contribution"
:
false
,
"task_completion_status"
:{
"count"
:
0
,
"completed_count"
:
0
...
...
lib/api/entities/merge_request.rb
View file @
c6519577
...
...
@@ -39,6 +39,16 @@ module API
expose
:diverged_commits_count
,
as: :diverged_commits_count
,
if:
->
(
_
,
options
)
{
options
[
:include_diverged_commits_count
]
}
# We put this into an option because list of TODOs API will attach their
# targets with Entities::MergeRequest instead of
# Entities::MergeRequestBasic, but this attribute cannot be eagerly
# loaded in batch for now. The list of merge requests API will
# use Entities::MergeRequestBasic which does not support this, and
# we always enable this for the single merge request API. This way
# we avoid N+1 queries in the TODOs API and can still enable it for
# the single merge request API.
expose
:first_contribution?
,
as: :first_contribution
,
if:
->
(
_
,
options
)
{
options
[
:include_first_contribution
]
}
def
build_available?
(
options
)
options
[
:project
]
&
.
feature_available?
(
:builds
,
options
[
:current_user
])
end
...
...
lib/api/merge_requests.rb
View file @
c6519577
...
...
@@ -267,6 +267,7 @@ module API
current_user:
current_user
,
project:
user_project
,
render_html:
params
[
:render_html
],
include_first_contribution:
true
,
include_diverged_commits_count:
params
[
:include_diverged_commits_count
],
include_rebase_in_progress:
params
[
:include_rebase_in_progress
]
end
...
...
spec/requests/api/merge_requests_spec.rb
View file @
c6519577
...
...
@@ -892,6 +892,7 @@ describe API::MergeRequests do
expect
(
json_response
[
'merge_error'
]).
to
eq
(
merge_request
.
merge_error
)
expect
(
json_response
[
'user'
][
'can_merge'
]).
to
be_truthy
expect
(
json_response
).
not_to
include
(
'rebase_in_progress'
)
expect
(
json_response
[
'first_contribution'
]).
to
be_falsy
expect
(
json_response
[
'has_conflicts'
]).
to
be_falsy
expect
(
json_response
[
'blocking_discussions_resolved'
]).
to
be_truthy
expect
(
json_response
[
'references'
][
'short'
]).
to
eq
(
"!
#{
merge_request
.
iid
}
"
)
...
...
@@ -915,6 +916,21 @@ describe API::MergeRequests do
expect
(
json_response
).
to
include
(
'rebase_in_progress'
)
end
context
'when author is not a member without any merged merge requests'
do
let
(
:non_member
)
{
create
(
:user
)
}
before
do
merge_request
.
update
(
author:
non_member
)
end
it
'exposes first_contribution as true'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'first_contribution'
]).
to
be_truthy
end
end
context
'merge_request_metrics'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
...
...
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