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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
2a75f979
Commit
2a75f979
authored
Mar 13, 2019
by
Natalia Tepluhina
Committed by
Phil Hughes
Mar 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added changelog entry
- fixed tests for edit components
parent
d3842c82
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
205 additions
and
48 deletions
+205
-48
app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue
...merge_request_widget/components/states/commits_header.vue
+14
-4
app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue
...merge_request_widget/components/states/ready_to_merge.vue
+42
-35
changelogs/unreleased/48324-enable-squash-message-on-fast-forward.yml
...nreleased/48324-enable-squash-message-on-fast-forward.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/javascripts/vue_mr_widget/components/states/mr_widget_commits_header_spec.js
...widget/components/states/mr_widget_commits_header_spec.js
+26
-0
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
...widget/components/states/mr_widget_ready_to_merge_spec.js
+112
-9
No files found.
app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue
View file @
2a75f979
...
@@ -14,6 +14,10 @@ export default {
...
@@ -14,6 +14,10 @@ export default {
type
:
Boolean
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
isFastForwardEnabled
:
{
type
:
Boolean
,
required
:
true
,
},
commitsCount
:
{
commitsCount
:
{
type
:
Number
,
type
:
Number
,
required
:
false
,
required
:
false
,
...
@@ -37,16 +41,22 @@ export default {
...
@@ -37,16 +41,22 @@ export default {
return
n__
(
__
(
'
%d commit
'
),
__
(
'
%d commits
'
),
this
.
isSquashEnabled
?
1
:
this
.
commitsCount
);
return
n__
(
__
(
'
%d commit
'
),
__
(
'
%d commits
'
),
this
.
isSquashEnabled
?
1
:
this
.
commitsCount
);
},
},
modifyLinkMessage
()
{
modifyLinkMessage
()
{
return
this
.
isSquashEnabled
?
__
(
'
Modify commit messages
'
)
:
__
(
'
Modify merge commit
'
);
if
(
this
.
isFastForwardEnabled
)
return
__
(
'
Modify commit message
'
);
else
if
(
this
.
isSquashEnabled
)
return
__
(
'
Modify commit messages
'
);
return
__
(
'
Modify merge commit
'
);
},
},
ariaLabel
()
{
ariaLabel
()
{
return
this
.
expanded
?
__
(
'
Collapse
'
)
:
__
(
'
Expand
'
);
return
this
.
expanded
?
__
(
'
Collapse
'
)
:
__
(
'
Expand
'
);
},
},
message
()
{
message
()
{
return
sprintf
(
const
message
=
this
.
isFastForwardEnabled
s__
(
?
s__
(
'
mrWidgetCommitsAdded|%{commitCount} will be added to %{targetBranch}.
'
)
:
s__
(
'
mrWidgetCommitsAdded|%{commitCount} and %{mergeCommitCount} will be added to %{targetBranch}.
'
,
'
mrWidgetCommitsAdded|%{commitCount} and %{mergeCommitCount} will be added to %{targetBranch}.
'
,
),
);
return
sprintf
(
message
,
{
{
commitCount
:
`<strong class="commits-count-message">
${
this
.
commitsCountMessage
}
</strong>`
,
commitCount
:
`<strong class="commits-count-message">
${
this
.
commitsCountMessage
}
</strong>`
,
mergeCommitCount
:
`<strong>
${
s__
(
'
mrWidgetCommitsAdded|1 merge commit
'
)}
</strong>`
,
mergeCommitCount
:
`<strong>
${
s__
(
'
mrWidgetCommitsAdded|1 merge commit
'
)}
</strong>`
,
...
...
app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue
View file @
2a75f979
...
@@ -113,6 +113,12 @@ export default {
...
@@ -113,6 +113,12 @@ export default {
shouldShowMergeControls
()
{
shouldShowMergeControls
()
{
return
this
.
mr
.
isMergeAllowed
||
this
.
shouldShowMergeWhenPipelineSucceedsText
;
return
this
.
mr
.
isMergeAllowed
||
this
.
shouldShowMergeWhenPipelineSucceedsText
;
},
},
shouldShowSquashEdit
()
{
return
this
.
squashBeforeMerge
&&
this
.
shouldShowSquashBeforeMerge
;
},
shouldShowMergeEdit
()
{
return
!
this
.
mr
.
ffOnlyEnabled
;
},
},
},
methods
:
{
methods
:
{
updateMergeCommitMessage
(
includeDescription
)
{
updateMergeCommitMessage
(
includeDescription
)
{
...
@@ -321,15 +327,16 @@ export default {
...
@@ -321,15 +327,16 @@ export default {
<div
v-if=
"mr.ffOnlyEnabled"
class=
"mr-fast-forward-message"
>
<div
v-if=
"mr.ffOnlyEnabled"
class=
"mr-fast-forward-message"
>
{{
__
(
'
Fast-forward merge without a merge commit
'
)
}}
{{
__
(
'
Fast-forward merge without a merge commit
'
)
}}
</div>
</div>
<template
v-else
>
<commits-header
<commits-header
v-if=
"shouldShowSquashEdit || shouldShowMergeEdit"
:is-squash-enabled=
"squashBeforeMerge"
:is-squash-enabled=
"squashBeforeMerge"
:commits-count=
"mr.commitsCount"
:commits-count=
"mr.commitsCount"
:target-branch=
"mr.targetBranch"
:target-branch=
"mr.targetBranch"
:is-fast-forward-enabled=
"mr.ffOnlyEnabled"
>
>
<ul
class=
"border-top content-list commits-list flex-list"
>
<ul
class=
"border-top content-list commits-list flex-list"
>
<commit-edit
<commit-edit
v-if=
"squashBeforeMerge && shouldShowSquashBeforeMerge
"
v-if=
"shouldShowSquashEdit
"
v-model=
"squashCommitMessage"
v-model=
"squashCommitMessage"
:label=
"__('Squash commit message')"
:label=
"__('Squash commit message')"
input-id=
"squash-message-edit"
input-id=
"squash-message-edit"
...
@@ -342,6 +349,7 @@ export default {
...
@@ -342,6 +349,7 @@ export default {
/>
/>
</commit-edit>
</commit-edit>
<commit-edit
<commit-edit
v-if=
"shouldShowMergeEdit"
v-model=
"commitMessage"
v-model=
"commitMessage"
:label=
"__('Merge commit message')"
:label=
"__('Merge commit message')"
input-id=
"merge-message-edit"
input-id=
"merge-message-edit"
...
@@ -358,6 +366,5 @@ export default {
...
@@ -358,6 +366,5 @@ export default {
</ul>
</ul>
</commits-header>
</commits-header>
</
template
>
</
template
>
</template>
</div>
</div>
</template>
</template>
changelogs/unreleased/48324-enable-squash-message-on-fast-forward.yml
0 → 100644
View file @
2a75f979
---
title
:
Allow modifying squash commit message for fast-forward only merge method
merge_request
:
26017
author
:
type
:
fixed
locale/gitlab.pot
View file @
2a75f979
...
@@ -4920,6 +4920,9 @@ msgstr ""
...
@@ -4920,6 +4920,9 @@ msgstr ""
msgid "Modal|Close"
msgid "Modal|Close"
msgstr ""
msgstr ""
msgid "Modify commit message"
msgstr ""
msgid "Modify commit messages"
msgid "Modify commit messages"
msgstr ""
msgstr ""
...
@@ -9089,6 +9092,9 @@ msgstr ""
...
@@ -9089,6 +9092,9 @@ msgstr ""
msgid "mrWidgetCommitsAdded|%{commitCount} and %{mergeCommitCount} will be added to %{targetBranch}."
msgid "mrWidgetCommitsAdded|%{commitCount} and %{mergeCommitCount} will be added to %{targetBranch}."
msgstr ""
msgstr ""
msgid "mrWidgetCommitsAdded|%{commitCount} will be added to %{targetBranch}."
msgstr ""
msgid "mrWidgetCommitsAdded|1 merge commit"
msgid "mrWidgetCommitsAdded|1 merge commit"
msgstr ""
msgstr ""
...
...
spec/javascripts/vue_mr_widget/components/states/mr_widget_commits_header_spec.js
View file @
2a75f979
...
@@ -15,6 +15,7 @@ describe('Commits header component', () => {
...
@@ -15,6 +15,7 @@ describe('Commits header component', () => {
isSquashEnabled
:
false
,
isSquashEnabled
:
false
,
targetBranch
:
'
master
'
,
targetBranch
:
'
master
'
,
commitsCount
:
5
,
commitsCount
:
5
,
isFastForwardEnabled
:
false
,
...
props
,
...
props
,
},
},
});
});
...
@@ -31,6 +32,27 @@ describe('Commits header component', () => {
...
@@ -31,6 +32,27 @@ describe('Commits header component', () => {
const
findTargetBranchMessage
=
()
=>
wrapper
.
find
(
'
.label-branch
'
);
const
findTargetBranchMessage
=
()
=>
wrapper
.
find
(
'
.label-branch
'
);
const
findModifyButton
=
()
=>
wrapper
.
find
(
'
.modify-message-button
'
);
const
findModifyButton
=
()
=>
wrapper
.
find
(
'
.modify-message-button
'
);
describe
(
'
when fast-forward is enabled
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
isFastForwardEnabled
:
true
,
isSquashEnabled
:
true
,
});
});
it
(
'
has commits count message showing 1 commit
'
,
()
=>
{
expect
(
findCommitsCountMessage
().
text
()).
toBe
(
'
1 commit
'
);
});
it
(
'
has button with modify commit message
'
,
()
=>
{
expect
(
findModifyButton
().
text
()).
toBe
(
'
Modify commit message
'
);
});
it
(
'
does not have merge commit part of the message
'
,
()
=>
{
expect
(
findHeaderWrapper
().
text
()).
not
.
toContain
(
'
1 merge commit
'
);
});
});
describe
(
'
when collapsed
'
,
()
=>
{
describe
(
'
when collapsed
'
,
()
=>
{
it
(
'
toggle has aria-label equal to Expand
'
,
()
=>
{
it
(
'
toggle has aria-label equal to Expand
'
,
()
=>
{
createComponent
();
createComponent
();
...
@@ -78,6 +100,10 @@ describe('Commits header component', () => {
...
@@ -78,6 +100,10 @@ describe('Commits header component', () => {
expect
(
findTargetBranchMessage
().
text
()).
toBe
(
'
master
'
);
expect
(
findTargetBranchMessage
().
text
()).
toBe
(
'
master
'
);
});
});
it
(
'
does has merge commit part of the message
'
,
()
=>
{
expect
(
findHeaderWrapper
().
text
()).
toContain
(
'
1 merge commit
'
);
});
});
});
describe
(
'
when expanded
'
,
()
=>
{
describe
(
'
when expanded
'
,
()
=>
{
...
...
spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js
View file @
2a75f979
...
@@ -18,6 +18,7 @@ const createTestMr = customConfig => {
...
@@ -18,6 +18,7 @@ const createTestMr = customConfig => {
isPipelinePassing
:
false
,
isPipelinePassing
:
false
,
isMergeAllowed
:
true
,
isMergeAllowed
:
true
,
onlyAllowMergeIfPipelineSucceeds
:
false
,
onlyAllowMergeIfPipelineSucceeds
:
false
,
ffOnlyEnabled
:
false
,
hasCI
:
false
,
hasCI
:
false
,
ciStatus
:
null
,
ciStatus
:
null
,
sha
:
'
12345678
'
,
sha
:
'
12345678
'
,
...
@@ -624,6 +625,10 @@ describe('ReadyToMerge', () => {
...
@@ -624,6 +625,10 @@ describe('ReadyToMerge', () => {
const
findCommitsHeaderElement
=
()
=>
wrapper
.
find
(
CommitsHeader
);
const
findCommitsHeaderElement
=
()
=>
wrapper
.
find
(
CommitsHeader
);
const
findCommitEditElements
=
()
=>
wrapper
.
findAll
(
CommitEdit
);
const
findCommitEditElements
=
()
=>
wrapper
.
findAll
(
CommitEdit
);
const
findCommitDropdownElement
=
()
=>
wrapper
.
find
(
CommitMessageDropdown
);
const
findCommitDropdownElement
=
()
=>
wrapper
.
find
(
CommitMessageDropdown
);
const
findFirstCommitEditLabel
=
()
=>
findCommitEditElements
()
.
at
(
0
)
.
props
(
'
label
'
);
describe
(
'
squash checkbox
'
,
()
=>
{
describe
(
'
squash checkbox
'
,
()
=>
{
it
(
'
should be rendered when squash before merge is enabled and there is more than 1 commit
'
,
()
=>
{
it
(
'
should be rendered when squash before merge is enabled and there is more than 1 commit
'
,
()
=>
{
...
@@ -648,31 +653,129 @@ describe('ReadyToMerge', () => {
...
@@ -648,31 +653,129 @@ describe('ReadyToMerge', () => {
});
});
describe
(
'
commits count collapsible header
'
,
()
=>
{
describe
(
'
commits count collapsible header
'
,
()
=>
{
it
(
'
should be rendered
if
fast-forward is disabled
'
,
()
=>
{
it
(
'
should be rendered
when
fast-forward is disabled
'
,
()
=>
{
createLocalComponent
();
createLocalComponent
();
expect
(
findCommitsHeaderElement
().
exists
()).
toBeTruthy
();
expect
(
findCommitsHeaderElement
().
exists
()).
toBeTruthy
();
});
});
it
(
'
should not be rendered if fast-forward is enabled
'
,
()
=>
{
describe
(
'
when fast-forward is enabled
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
}
});
it
(
'
should be rendered if squash and squash before are enabled and there is more than 1 commit
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
enableSquashBeforeMerge
:
true
,
squash
:
true
,
commitsCount
:
2
,
},
});
expect
(
findCommitsHeaderElement
().
exists
()).
toBeTruthy
();
});
it
(
'
should not be rendered if squash before merge is disabled
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
enableSquashBeforeMerge
:
false
,
squash
:
true
,
commitsCount
:
2
,
},
});
expect
(
findCommitsHeaderElement
().
exists
()).
toBeFalsy
();
expect
(
findCommitsHeaderElement
().
exists
()).
toBeFalsy
();
});
});
it
(
'
should not be rendered if squash is disabled
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
squash
:
false
,
enableSquashBeforeMerge
:
true
,
commitsCount
:
2
,
},
});
expect
(
findCommitsHeaderElement
().
exists
()).
toBeFalsy
();
});
it
(
'
should not be rendered if commits count is 1
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
squash
:
true
,
enableSquashBeforeMerge
:
true
,
commitsCount
:
1
,
},
});
expect
(
findCommitsHeaderElement
().
exists
()).
toBeFalsy
();
});
});
});
});
describe
(
'
commits edit components
'
,
()
=>
{
describe
(
'
commits edit components
'
,
()
=>
{
describe
(
'
when fast-forward merge is enabled
'
,
()
=>
{
it
(
'
should not be rendered if squash is disabled
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
squash
:
false
,
enableSquashBeforeMerge
:
true
,
commitsCount
:
2
,
},
});
expect
(
findCommitEditElements
().
length
).
toBe
(
0
);
});
it
(
'
should not be rendered if squash before merge is disabled
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
squash
:
true
,
enableSquashBeforeMerge
:
false
,
commitsCount
:
2
,
},
});
expect
(
findCommitEditElements
().
length
).
toBe
(
0
);
});
it
(
'
should not be rendered if there is only one commit
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
squash
:
true
,
enableSquashBeforeMerge
:
true
,
commitsCount
:
1
,
},
});
expect
(
findCommitEditElements
().
length
).
toBe
(
0
);
});
it
(
'
should have one edit component if squash is enabled and there is more than 1 commit
'
,
()
=>
{
createLocalComponent
({
mr
:
{
ffOnlyEnabled
:
true
,
squash
:
true
,
enableSquashBeforeMerge
:
true
,
commitsCount
:
2
,
},
});
expect
(
findCommitEditElements
().
length
).
toBe
(
1
);
expect
(
findFirstCommitEditLabel
()).
toBe
(
'
Squash commit message
'
);
});
});
it
(
'
should have one edit component when squash is disabled
'
,
()
=>
{
it
(
'
should have one edit component when squash is disabled
'
,
()
=>
{
createLocalComponent
();
createLocalComponent
();
expect
(
findCommitEditElements
().
length
).
toBe
(
1
);
expect
(
findCommitEditElements
().
length
).
toBe
(
1
);
});
});
const
findFirstCommitEditLabel
=
()
=>
findCommitEditElements
()
.
at
(
0
)
.
props
(
'
label
'
);
it
(
'
should have two edit components when squash is enabled and there is more than 1 commit
'
,
()
=>
{
it
(
'
should have two edit components when squash is enabled and there is more than 1 commit
'
,
()
=>
{
createLocalComponent
({
createLocalComponent
({
mr
:
{
mr
:
{
...
...
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