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
becb86ea
Commit
becb86ea
authored
Oct 03, 2018
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pipeline status to diffs/commit_item
**Notes:** - Also exposes commit.pipeline_status_path in diffs.json
parent
5a286eb7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
3 deletions
+53
-3
app/assets/javascripts/diffs/components/commit_item.vue
app/assets/javascripts/diffs/components/commit_item.vue
+6
-0
app/models/commit.rb
app/models/commit.rb
+5
-1
app/serializers/commit_entity.rb
app/serializers/commit_entity.rb
+11
-0
app/serializers/diffs_entity.rb
app/serializers/diffs_entity.rb
+3
-1
spec/javascripts/diffs/components/commit_item_spec.js
spec/javascripts/diffs/components/commit_item_spec.js
+17
-0
spec/serializers/commit_entity_spec.rb
spec/serializers/commit_entity_spec.rb
+11
-1
No files found.
app/assets/javascripts/diffs/components/commit_item.vue
View file @
becb86ea
...
...
@@ -5,6 +5,7 @@ import Icon from '~/vue_shared/components/icon.vue';
import
ClipboardButton
from
'
~/vue_shared/components/clipboard_button.vue
'
;
import
CIIcon
from
'
~/vue_shared/components/ci_icon.vue
'
;
import
TimeAgoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
CommitPipelineStatus
from
'
~/projects/tree/components/commit_pipeline_status_component.vue
'
;
/**
* CommitItem
...
...
@@ -29,6 +30,7 @@ export default {
ClipboardButton
,
CIIcon
,
TimeAgoTooltip
,
CommitPipelineStatus
,
},
props
:
{
commit
:
{
...
...
@@ -106,6 +108,10 @@ export default {
v-if=
"commit.signatureHtml"
v-html=
"commit.signatureHtml"
></div>
<commit-pipeline-status
v-if=
"commit.pipelineStatusPath"
:endpoint=
"commit.pipelineStatusPath"
/>
<div
class=
"commit-sha-group"
>
<div
class=
"label label-monospace"
...
...
app/models/commit.rb
View file @
becb86ea
...
...
@@ -319,7 +319,11 @@ class Commit
def
status
(
ref
=
nil
)
return
@statuses
[
ref
]
if
@statuses
.
key?
(
ref
)
@statuses
[
ref
]
=
project
.
pipelines
.
latest_status_per_commit
(
id
,
ref
)[
id
]
@statuses
[
ref
]
=
status_for_project
(
ref
,
project
)
end
def
status_for_project
(
ref
,
pipeline_project
)
pipeline_project
.
pipelines
.
latest_status_per_commit
(
id
,
ref
)[
id
]
end
def
set_status_for_ref
(
ref
,
status
)
...
...
app/serializers/commit_entity.rb
View file @
becb86ea
...
...
@@ -30,6 +30,17 @@ class CommitEntity < API::Entities::Commit
render
(
'projects/commit/_signature'
,
signature:
commit
.
signature
)
if
commit
.
has_signature?
end
expose
:pipeline_status_path
,
if:
{
type: :full
}
do
|
commit
,
options
|
pipeline_ref
=
options
[
:pipeline_ref
]
pipeline_project
=
options
[
:pipeline_project
]
||
commit
.
project
next
unless
pipeline_ref
&&
pipeline_project
status
=
commit
.
status_for_project
(
pipeline_ref
,
pipeline_project
)
next
unless
status
pipelines_project_commit_path
(
pipeline_project
,
commit
.
id
,
ref:
pipeline_ref
)
end
def
render
(
*
args
)
return
unless
request
.
respond_to?
(
:render
)
&&
request
.
render
.
respond_to?
(
:call
)
...
...
app/serializers/diffs_entity.rb
View file @
becb86ea
...
...
@@ -18,7 +18,9 @@ class DiffsEntity < Grape::Entity
expose
:commit
do
|
diffs
,
options
|
CommitEntity
.
represent
options
[
:commit
],
options
.
merge
(
type: :full
,
commit_url_params:
{
merge_request_iid:
merge_request
&
.
iid
}
commit_url_params:
{
merge_request_iid:
merge_request
&
.
iid
},
pipeline_ref:
merge_request
&
.
source_branch
,
pipeline_project:
merge_request
&
.
source_project
)
end
...
...
spec/javascripts/diffs/components/commit_item_spec.js
View file @
becb86ea
...
...
@@ -10,6 +10,7 @@ const TEST_AUTHOR_NAME = 'test';
const
TEST_AUTHOR_EMAIL
=
'
test+test@gitlab.com
'
;
const
TEST_AUTHOR_GRAVATAR
=
`
${
TEST_HOST
}
/avatar/test?s=36`
;
const
TEST_SIGNATURE_HTML
=
'
<a>Legit commit</a>
'
;
const
TEST_PIPELINE_STATUS_PATH
=
`
${
TEST_HOST
}
/pipeline/status`
;
const
getTitleElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-row-message.item-title
'
);
const
getDescElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
pre.commit-row-description
'
);
...
...
@@ -143,4 +144,20 @@ describe('diffs/components/commit_widget', () => {
expect
(
actionsElement
).
toContainHtml
(
TEST_SIGNATURE_HTML
);
});
});
describe
(
'
with pipeline status
'
,
()
=>
{
beforeEach
(
done
=>
{
vm
.
commit
.
pipelineStatusPath
=
TEST_PIPELINE_STATUS_PATH
;
vm
.
$nextTick
()
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
renders pipeline status
'
,
()
=>
{
const
actionsElement
=
getCommitActionsElement
(
vm
);
expect
(
actionsElement
).
toContainElement
(
'
.ci-status-link
'
);
});
});
});
spec/serializers/commit_entity_spec.rb
View file @
becb86ea
...
...
@@ -66,7 +66,7 @@ describe CommitEntity do
context
'when type is "full"'
do
let
(
:entity
)
do
described_class
.
new
(
commit
,
request:
request
,
type: :full
)
described_class
.
new
(
commit
,
request:
request
,
type: :full
,
pipeline_ref:
project
.
default_branch
,
pipeline_project:
project
)
end
it
'exposes extra properties'
do
...
...
@@ -84,6 +84,16 @@ describe CommitEntity do
expect
(
subject
.
fetch
(
:signature_html
)).
to
be
SIGNATURE_HTML
end
end
context
'when commit has pipeline'
do
before
do
create
(
:ci_pipeline
,
project:
project
,
sha:
commit
.
id
)
end
it
'exposes "pipeline_status_path"'
do
expect
(
subject
.
fetch
(
:pipeline_status_path
)).
not_to
be_nil
end
end
end
context
'when commit_url_params is set'
do
...
...
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