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
5a286eb7
Commit
5a286eb7
authored
Oct 03, 2018
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add signature badge to diffs/commit_item
**Notes:** - Also exposes commit.signature_html in diffs.json
parent
c375171b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
2 deletions
+54
-2
app/assets/javascripts/diffs/components/commit_item.vue
app/assets/javascripts/diffs/components/commit_item.vue
+4
-0
app/controllers/projects/merge_requests/diffs_controller.rb
app/controllers/projects/merge_requests/diffs_controller.rb
+7
-1
app/serializers/commit_entity.rb
app/serializers/commit_entity.rb
+10
-0
spec/javascripts/diffs/components/commit_item_spec.js
spec/javascripts/diffs/components/commit_item_spec.js
+18
-0
spec/serializers/commit_entity_spec.rb
spec/serializers/commit_entity_spec.rb
+15
-1
No files found.
app/assets/javascripts/diffs/components/commit_item.vue
View file @
5a286eb7
...
@@ -102,6 +102,10 @@ export default {
...
@@ -102,6 +102,10 @@ export default {
></pre>
></pre>
</div>
</div>
<div
class=
"commit-actions flex-row d-none d-sm-flex"
>
<div
class=
"commit-actions flex-row d-none d-sm-flex"
>
<div
v-if=
"commit.signatureHtml"
v-html=
"commit.signatureHtml"
></div>
<div
class=
"commit-sha-group"
>
<div
class=
"commit-sha-group"
>
<div
<div
class=
"label label-monospace"
class=
"label label-monospace"
...
...
app/controllers/projects/merge_requests/diffs_controller.rb
View file @
5a286eb7
...
@@ -25,7 +25,13 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
...
@@ -25,7 +25,13 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@diffs
.
write_cache
@diffs
.
write_cache
render
json:
DiffsSerializer
.
new
(
current_user:
current_user
,
project:
@merge_request
.
project
).
represent
(
@diffs
,
additional_attributes
)
request
=
{
current_user:
current_user
,
project:
@merge_request
.
project
,
render:
->
(
partial
,
locals
)
{
view_to_html_string
(
partial
,
locals
)
}
}
render
json:
DiffsSerializer
.
new
(
request
).
represent
(
@diffs
,
additional_attributes
)
end
end
def
define_diff_vars
def
define_diff_vars
...
...
app/serializers/commit_entity.rb
View file @
5a286eb7
...
@@ -25,4 +25,14 @@ class CommitEntity < API::Entities::Commit
...
@@ -25,4 +25,14 @@ class CommitEntity < API::Entities::Commit
expose
:title_html
,
if:
{
type: :full
}
do
|
commit
|
expose
:title_html
,
if:
{
type: :full
}
do
|
commit
|
markdown_field
(
commit
,
:title
)
markdown_field
(
commit
,
:title
)
end
end
expose
:signature_html
,
if:
{
type: :full
}
do
|
commit
|
render
(
'projects/commit/_signature'
,
signature:
commit
.
signature
)
if
commit
.
has_signature?
end
def
render
(
*
args
)
return
unless
request
.
respond_to?
(
:render
)
&&
request
.
render
.
respond_to?
(
:call
)
request
.
render
.
call
(
*
args
)
end
end
end
spec/javascripts/diffs/components/commit_item_spec.js
View file @
5a286eb7
...
@@ -9,6 +9,7 @@ import getDiffWithCommit from '../mock_data/diff_with_commit';
...
@@ -9,6 +9,7 @@ import getDiffWithCommit from '../mock_data/diff_with_commit';
const
TEST_AUTHOR_NAME
=
'
test
'
;
const
TEST_AUTHOR_NAME
=
'
test
'
;
const
TEST_AUTHOR_EMAIL
=
'
test+test@gitlab.com
'
;
const
TEST_AUTHOR_EMAIL
=
'
test+test@gitlab.com
'
;
const
TEST_AUTHOR_GRAVATAR
=
`
${
TEST_HOST
}
/avatar/test?s=36`
;
const
TEST_AUTHOR_GRAVATAR
=
`
${
TEST_HOST
}
/avatar/test?s=36`
;
const
TEST_SIGNATURE_HTML
=
'
<a>Legit commit</a>
'
;
const
getTitleElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-row-message.item-title
'
);
const
getTitleElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-row-message.item-title
'
);
const
getDescElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
pre.commit-row-description
'
);
const
getDescElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
pre.commit-row-description
'
);
...
@@ -16,6 +17,7 @@ const getDescExpandElement = vm => vm.$el.querySelector('.commit-content .text-e
...
@@ -16,6 +17,7 @@ const getDescExpandElement = vm => vm.$el.querySelector('.commit-content .text-e
const
getShaElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-sha-group
'
);
const
getShaElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-sha-group
'
);
const
getAvatarElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.user-avatar-link
'
);
const
getAvatarElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.user-avatar-link
'
);
const
getCommitterElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commiter
'
);
const
getCommitterElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commiter
'
);
const
getCommitActionsElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-actions
'
);
describe
(
'
diffs/components/commit_widget
'
,
()
=>
{
describe
(
'
diffs/components/commit_widget
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
CommitItem
);
const
Component
=
Vue
.
extend
(
CommitItem
);
...
@@ -125,4 +127,20 @@ describe('diffs/components/commit_widget', () => {
...
@@ -125,4 +127,20 @@ describe('diffs/components/commit_widget', () => {
expect
(
nameElement
).
toHaveText
(
TEST_AUTHOR_NAME
);
expect
(
nameElement
).
toHaveText
(
TEST_AUTHOR_NAME
);
});
});
});
});
describe
(
'
with signature
'
,
()
=>
{
beforeEach
(
done
=>
{
vm
.
commit
.
signatureHtml
=
TEST_SIGNATURE_HTML
;
vm
.
$nextTick
()
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
renders signature html
'
,
()
=>
{
const
actionsElement
=
getCommitActionsElement
(
vm
);
expect
(
actionsElement
).
toContainHtml
(
TEST_SIGNATURE_HTML
);
});
});
});
});
spec/serializers/commit_entity_spec.rb
View file @
5a286eb7
require
'spec_helper'
require
'spec_helper'
describe
CommitEntity
do
describe
CommitEntity
do
SIGNATURE_HTML
=
'TEST'
.
freeze
let
(
:entity
)
do
let
(
:entity
)
do
described_class
.
new
(
commit
,
request:
request
)
described_class
.
new
(
commit
,
request:
request
)
end
end
let
(
:request
)
{
double
(
'request'
)
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:commit
)
{
project
.
commit
}
let
(
:commit
)
{
project
.
commit
}
...
@@ -12,7 +13,11 @@ describe CommitEntity do
...
@@ -12,7 +13,11 @@ describe CommitEntity do
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
before
do
before
do
render
=
double
(
'render'
)
allow
(
render
).
to
receive
(
:call
).
and_return
(
SIGNATURE_HTML
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
allow
(
request
).
to
receive
(
:render
).
and_return
(
render
)
end
end
context
'when commit author is a user'
do
context
'when commit author is a user'
do
...
@@ -70,6 +75,15 @@ describe CommitEntity do
...
@@ -70,6 +75,15 @@ describe CommitEntity do
expect
(
subject
.
fetch
(
:description_html
)).
not_to
be_nil
expect
(
subject
.
fetch
(
:description_html
)).
not_to
be_nil
expect
(
subject
.
fetch
(
:title_html
)).
not_to
be_nil
expect
(
subject
.
fetch
(
:title_html
)).
not_to
be_nil
end
end
context
'when commit has signature'
do
let
(
:commit
)
{
project
.
commit
(
TestEnv
::
BRANCH_SHA
[
'signed-commits'
])
}
it
'exposes "signature_html"'
do
expect
(
request
.
render
).
to
receive
(
:call
)
expect
(
subject
.
fetch
(
:signature_html
)).
to
be
SIGNATURE_HTML
end
end
end
end
context
'when commit_url_params is set'
do
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