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
Léo-Paul Géneau
gitlab-ce
Commits
58609f84
Commit
58609f84
authored
Nov 28, 2016
by
Gabriel Gizotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backend completely drives creation of merge commit message
parent
512c870e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
26 deletions
+37
-26
app/models/merge_request.rb
app/models/merge_request.rb
+2
-1
app/views/projects/merge_requests/widget/_open.html.haml
app/views/projects/merge_requests/widget/_open.html.haml
+1
-2
app/views/projects/merge_requests/widget/open/_accept.html.haml
...ews/projects/merge_requests/widget/open/_accept.html.haml
+2
-1
app/views/shared/_commit_message_container.html.haml
app/views/shared/_commit_message_container.html.haml
+18
-22
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+14
-0
No files found.
app/models/merge_request.rb
View file @
58609f84
...
...
@@ -628,7 +628,7 @@ class MergeRequest < ActiveRecord::Base
self
.
target_project
.
repository
.
branch_names
.
include?
(
self
.
target_branch
)
end
def
merge_commit_message
def
merge_commit_message
(
include_description:
false
)
closes_issues_references
=
closes_issues
.
map
do
|
issue
|
issue
.
to_reference
(
target_project
)
end
...
...
@@ -640,6 +640,7 @@ class MergeRequest < ActiveRecord::Base
message
<<
"Closed Issues:
#{
closes_issues_references
.
join
(
", "
)
}
\n\n
"
end
message
<<
"
#{
description
}
\n\n
"
if
include_description
&&
description
.
present?
message
<<
"See merge request
#{
to_reference
}
"
message
...
...
app/views/projects/merge_requests/widget/_open.html.haml
View file @
58609f84
...
...
@@ -37,12 +37,11 @@
#{
"Issue"
.
pluralize
(
mr_issues_mentioned_but_not_closing
.
size
)
}
mentioned but not being closed:
=
succeed
'.'
do
!=
markdown
issues_sentence
(
mr_issues_mentioned_but_not_closing
),
pipeline: :gfm
,
author:
@merge_request
.
author
=
mr_assign_issues_link
-
if
mr_closes_issues
.
present?
.mr-widget-footer
%span
%i
.fa.fa-check
=
icon
(
'check'
)
Accepting this merge request will close
#{
"issue"
.
pluralize
(
mr_closes_issues
.
size
)
}
=
succeed
'.'
do
!=
markdown
issues_sentence
(
mr_closes_issues
),
pipeline: :gfm
,
author:
@merge_request
.
author
...
...
app/views/projects/merge_requests/widget/open/_accept.html.haml
View file @
58609f84
...
...
@@ -41,7 +41,8 @@
Modify commit message
.js-toggle-content.hide.prepend-top-default
=
render
'shared/commit_message_container'
,
params:
params
,
description:
@merge_request
.
description
,
message_with_description:
@merge_request
.
merge_commit_message
(
include_description:
true
),
message_without_description:
@merge_request
.
merge_commit_message
,
text:
@merge_request
.
merge_commit_message
,
rows:
14
,
hint:
true
...
...
app/views/shared/_commit_message_container.html.haml
View file @
58609f84
...
...
@@ -8,42 +8,38 @@
=
text_area_tag
'commit_message'
,
(
params
[
:commit_message
]
||
local_assigns
[
:text
]
||
local_assigns
[
:placeholder
]),
class:
'form-control js-commit-message'
,
placeholder:
local_assigns
[
:placeholder
],
data:
local_assigns
.
slice
(
:message_with_description
,
:message_without_description
),
required:
true
,
rows:
(
local_assigns
[
:rows
]
||
3
),
id:
"commit_message-
#{
nonce
}
"
-
if
local_assigns
[
:hint
]
%p
.hint
Try to keep the first line under 52 characters
and the others under 72.
-
if
local_assigns
[
:description
]
%p
.hint.
use
-description-hint
=
link_to
"#"
,
class:
"
use
-description-link"
do
Use Merge Request description as merge
commit message
%p
.hint.
use-default-message
-hint.hide
=
link_to
"#"
,
class:
"
use-default-message
-link"
do
Use default Gitlab merge
commit message
-
if
local_assigns
.
slice
(
:message_with_description
,
:message_without_description
).
present?
%p
.hint.
with
-description-hint
=
link_to
"#"
,
class:
"
with
-description-link"
do
Include description in
commit message
%p
.hint.
without-description
-hint.hide
=
link_to
"#"
,
class:
"
without-description
-link"
do
Don't include description in
commit message
:javascript
$
(
'
.
use
-description-link
'
).
on
(
'
click
'
,
function
(
e
)
{
$
(
'
.
with
-description-link
'
).
on
(
'
click
'
,
function
(
e
)
{
e
.
preventDefault
();
var
message
=
"
Merge branch '
#{
j
@merge_request
.
source_branch
}
' into '
#{
j
@merge_request
.
target_branch
}
'
\n\n
"
message
=
message
+
"
#{
j
@merge_request
.
title
}
\n\n
"
message
=
message
+
"
#{
j
local_assigns
[
:description
]
}
\n\n
"
;
message
=
message
+
"
See merge request
#{
j
@merge_request
.
to_reference
}
"
var
textarea
=
$
(
'
.js-commit-message
'
)
$
(
'
.use-description-hint
'
).
hide
();
$
(
'
.use-default-message-hint
'
).
show
();
$
(
'
.js-commit-message
'
).
val
(
message
)
textarea
.
val
(
textarea
.
data
(
'
messageWithDescription
'
))
$
(
'
.with-description-hint
'
).
hide
();
$
(
'
.without-description-hint
'
).
show
();
});
$
(
'
.
use-default-message
-link
'
).
on
(
'
click
'
,
function
(
e
)
{
$
(
'
.
without-description
-link
'
).
on
(
'
click
'
,
function
(
e
)
{
e
.
preventDefault
();
var
defaultMessage
=
"
#{
j
(
params
[
:commit_message
]
||
local_assigns
[
:text
]
||
local_assigns
[
:placeholder
])
}
"
;
var
textarea
=
$
(
'
.js-commit-message
'
)
$
(
'
.use-description-hint
'
).
show
();
$
(
'
.
use-default-message-hint
'
).
hide
();
$
(
'
.
js-commit-message
'
).
val
(
defaultMessage
);
textarea
.
val
(
textarea
.
data
(
'
messageWithoutDescription
'
))
$
(
'
.
with-description-hint
'
).
show
();
$
(
'
.
without-description-hint
'
).
hide
(
);
});
spec/models/merge_request_spec.rb
View file @
58609f84
...
...
@@ -440,6 +440,20 @@ describe MergeRequest, models: true do
expect
(
request
.
merge_commit_message
).
not_to
match
(
"Title
\n\n\n\n
"
)
end
it
'includes its description in the body'
do
request
=
build
(
:merge_request
,
description:
'By removing all code'
)
expect
(
request
.
merge_commit_message
(
include_description:
true
))
.
to
match
(
"By removing all code
\n\n
"
)
end
it
'does not includes its description in the body'
do
request
=
build
(
:merge_request
,
description:
'By removing all code'
)
expect
(
request
.
merge_commit_message
)
.
not_to
match
(
"By removing all code
\n\n
"
)
end
end
describe
"#reset_merge_when_build_succeeds"
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