Commit b86443c4 authored by Phil Hughes's avatar Phil Hughes

Merge branch '28822-no-commit-message' into 'master'

Change --no-commit-message to No commit message

Closes #28822

See merge request gitlab-org/gitlab!22765
parents 9e85c758 31dee2e5
...@@ -104,7 +104,11 @@ export default { ...@@ -104,7 +104,11 @@ export default {
</span> </span>
<div class="commit-detail flex-list"> <div class="commit-detail flex-list">
<div class="commit-content qa-commit-content"> <div class="commit-content qa-commit-content">
<gl-link :href="commit.webUrl" class="commit-row-message item-title"> <gl-link
:href="commit.webUrl"
:class="{ 'font-italic': !commit.message }"
class="commit-row-message item-title"
>
{{ commit.title }} {{ commit.title }}
</gl-link> </gl-link>
<gl-button <gl-button
......
...@@ -6,6 +6,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { ...@@ -6,6 +6,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
sha sha
title title
description description
message
webUrl webUrl
authoredDate authoredDate
authorName authorName
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
.commit-detail.flex-list .commit-detail.flex-list
.commit-content.qa-commit-content .commit-content.qa-commit-content
- if view_details && merge_request - if view_details && merge_request
= link_to commit.title, project_commit_path(project, commit.id, merge_request_iid: merge_request.iid), class: "commit-row-message item-title js-onboarding-commit-item" = link_to commit.title, project_commit_path(project, commit.id, merge_request_iid: merge_request.iid), class: ["commit-row-message item-title js-onboarding-commit-item", ("font-italic" if commit.message.empty?)]
- else - else
= link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item") = link_to_markdown_field(commit, :title, link, class: "commit-row-message item-title js-onboarding-commit-item #{"font-italic" if commit.message.empty?}")
%span.commit-row-message.d-inline.d-sm-none %span.commit-row-message.d-inline.d-sm-none
&middot; &middot;
= commit.short_id = commit.short_id
......
---
title: Updated no commit verbiage
merge_request: 22765
author:
type: other
...@@ -254,7 +254,7 @@ module Gitlab ...@@ -254,7 +254,7 @@ module Gitlab
end end
def no_commit_message def no_commit_message
"--no commit message" "No commit message"
end end
def to_hash def to_hash
......
...@@ -6,7 +6,7 @@ import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link ...@@ -6,7 +6,7 @@ import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link
let vm; let vm;
function createCommitData(data = {}) { function createCommitData(data = {}) {
return { const defaultData = {
sha: '123456789', sha: '123456789',
title: 'Commit title', title: 'Commit title',
message: 'Commit message', message: 'Commit message',
...@@ -26,8 +26,8 @@ function createCommitData(data = {}) { ...@@ -26,8 +26,8 @@ function createCommitData(data = {}) {
group: {}, group: {},
}, },
}, },
...data,
}; };
return Object.assign(defaultData, data);
} }
function factory(commit = createCommitData(), loading = false) { function factory(commit = createCommitData(), loading = false) {
...@@ -46,6 +46,8 @@ function factory(commit = createCommitData(), loading = false) { ...@@ -46,6 +46,8 @@ function factory(commit = createCommitData(), loading = false) {
vm.vm.$apollo.queries.commit.loading = loading; vm.vm.$apollo.queries.commit.loading = loading;
} }
const emptyMessageClass = 'font-italic';
describe('Repository last commit component', () => { describe('Repository last commit component', () => {
afterEach(() => { afterEach(() => {
vm.destroy(); vm.destroy();
...@@ -135,4 +137,12 @@ describe('Repository last commit component', () => { ...@@ -135,4 +137,12 @@ describe('Repository last commit component', () => {
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
}); });
}); });
it('sets correct CSS class if the commit message is empty', () => {
factory(createCommitData({ message: '' }));
return vm.vm.$nextTick().then(() => {
expect(vm.find('.item-title').classes()).toContain(emptyMessageClass);
});
});
}); });
...@@ -57,7 +57,7 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -57,7 +57,7 @@ describe Gitlab::Git::Commit, :seed_helper do
it { expect(@commit.different_committer?).to be_truthy } it { expect(@commit.different_committer?).to be_truthy }
it { expect(@commit.parents).to eq(@gitlab_parents) } it { expect(@commit.parents).to eq(@gitlab_parents) }
it { expect(@commit.parent_id).to eq(@parents.first.oid) } it { expect(@commit.parent_id).to eq(@parents.first.oid) }
it { expect(@commit.no_commit_message).to eq("--no commit message") } it { expect(@commit.no_commit_message).to eq("No commit message") }
after do after do
# Erase the new commit so other tests get the original repo # Erase the new commit so other tests get the original repo
......
...@@ -277,7 +277,7 @@ describe Commit do ...@@ -277,7 +277,7 @@ describe Commit do
describe '#title' do describe '#title' do
it "returns no_commit_message when safe_message is blank" do it "returns no_commit_message when safe_message is blank" do
allow(commit).to receive(:safe_message).and_return('') allow(commit).to receive(:safe_message).and_return('')
expect(commit.title).to eq("--no commit message") expect(commit.title).to eq("No commit message")
end end
it 'truncates a message without a newline at natural break to 80 characters' do it 'truncates a message without a newline at natural break to 80 characters' do
...@@ -308,7 +308,7 @@ eos ...@@ -308,7 +308,7 @@ eos
describe '#full_title' do describe '#full_title' do
it "returns no_commit_message when safe_message is blank" do it "returns no_commit_message when safe_message is blank" do
allow(commit).to receive(:safe_message).and_return('') allow(commit).to receive(:safe_message).and_return('')
expect(commit.full_title).to eq("--no commit message") expect(commit.full_title).to eq("No commit message")
end end
it "returns entire message if there is no newline" do it "returns entire message if there is no newline" do
...@@ -330,7 +330,7 @@ eos ...@@ -330,7 +330,7 @@ eos
it 'returns no_commit_message when safe_message is blank' do it 'returns no_commit_message when safe_message is blank' do
allow(commit).to receive(:safe_message).and_return(nil) allow(commit).to receive(:safe_message).and_return(nil)
expect(commit.description).to eq('--no commit message') expect(commit.description).to eq('No commit message')
end end
it 'returns description of commit message if title less than 100 characters' do it 'returns description of commit message if title less than 100 characters' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment