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
2dcbe3d2
Commit
2dcbe3d2
authored
May 31, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code climate artifact code on backend
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
a04a9c38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
17 deletions
+12
-17
app/models/merge_request.rb
app/models/merge_request.rb
+4
-9
app/serializers/merge_request_entity.rb
app/serializers/merge_request_entity.rb
+8
-8
No files found.
app/models/merge_request.rb
View file @
2dcbe3d2
...
@@ -34,6 +34,9 @@ class MergeRequest < ActiveRecord::Base
...
@@ -34,6 +34,9 @@ class MergeRequest < ActiveRecord::Base
delegate
:commits
,
:real_size
,
:commits_sha
,
:commits_count
,
delegate
:commits
,
:real_size
,
:commits_sha
,
:commits_count
,
to: :merge_request_diff
,
prefix:
nil
to: :merge_request_diff
,
prefix:
nil
delegate
:codeclimate_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:codeclimate_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
# When this attribute is true some MR validation is ignored
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
# It allows us to close or modify broken merge requests
attr_accessor
:allow_broken
attr_accessor
:allow_broken
...
@@ -996,16 +999,8 @@ class MergeRequest < ActiveRecord::Base
...
@@ -996,16 +999,8 @@ class MergeRequest < ActiveRecord::Base
@base_pipeline
||=
project
.
pipelines
.
find_by
(
sha:
merge_request_diff
&
.
base_commit_sha
)
@base_pipeline
||=
project
.
pipelines
.
find_by
(
sha:
merge_request_diff
&
.
base_commit_sha
)
end
end
def
codeclimate_artifact
@codeclimate_artifact
||=
head_pipeline
&
.
codeclimate_artifact
end
def
base_codeclimate_artifact
@base_codeclimate_artifact
||=
base_pipeline
&
.
codeclimate_artifact
end
def
has_codeclimate_data?
def
has_codeclimate_data?
codeclimate_artifact
&
.
success?
&&
head_
codeclimate_artifact
&
.
success?
&&
base_codeclimate_artifact
&
.
success?
base_codeclimate_artifact
&
.
success?
end
end
end
end
app/serializers/merge_request_entity.rb
View file @
2dcbe3d2
...
@@ -197,17 +197,17 @@ class MergeRequestEntity < IssuableEntity
...
@@ -197,17 +197,17 @@ class MergeRequestEntity < IssuableEntity
end
end
# EE-specific
# EE-specific
expose
:codeclimate
,
if:
lambda
{
|
mr
,
_
|
mr
.
has_codeclimate_data?
&&
can?
(
current_user
,
:read_build
,
mr
.
project
)
}
do
expose
:codeclimate
,
if:
->
(
mr
,
_
)
{
mr
.
has_codeclimate_data?
}
do
expose
:head_path
do
|
merge_request
|
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_codeclimate_artifact
)
}
do
|
merge_request
|
raw_namespace_project_build_artifacts_url
(
merge_request
.
project
.
namespace
,
raw_namespace_project_build_artifacts_url
(
merge_request
.
source_
project
.
namespace
,
merge_request
.
project
,
merge_request
.
source_
project
,
merge_request
.
codeclimate_artifact
,
merge_request
.
head_
codeclimate_artifact
,
path:
'codeclimate.json'
)
path:
'codeclimate.json'
)
end
end
expose
:base_path
do
|
merge_request
|
expose
:base_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
base_codeclimate_artifact
)
}
do
|
merge_request
|
raw_namespace_project_build_artifacts_url
(
merge_request
.
project
.
namespace
,
raw_namespace_project_build_artifacts_url
(
merge_request
.
target_
project
.
namespace
,
merge_request
.
project
,
merge_request
.
target_
project
,
merge_request
.
base_codeclimate_artifact
,
merge_request
.
base_codeclimate_artifact
,
path:
'codeclimate.json'
)
path:
'codeclimate.json'
)
end
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