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
0b942541
Commit
0b942541
authored
Mar 18, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the "easy WIP & un-WIP from link" feature
parent
d4b49587
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
59 deletions
+53
-59
app/assets/javascripts/issuable_form.js.coffee
app/assets/javascripts/issuable_form.js.coffee
+19
-19
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+2
-5
app/services/system_note_service.rb
app/services/system_note_service.rb
+2
-2
app/views/projects/merge_requests/widget/open/_wip.html.haml
app/views/projects/merge_requests/widget/open/_wip.html.haml
+8
-8
app/views/shared/issuable/_form.html.haml
app/views/shared/issuable/_form.html.haml
+11
-6
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+10
-18
No files found.
app/assets/javascripts/issuable_form.js.coffee
View file @
0b942541
class
@
IssuableForm
class
@
IssuableForm
wipRegex
:
/^\
[?WIP(\]|:| )
\s*/i
wipRegex
:
/^\
s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+
\s*/i
constructor
:
(
@
form
)
->
constructor
:
(
@
form
)
->
GitLab
.
GfmAutoComplete
.
setup
()
GitLab
.
GfmAutoComplete
.
setup
()
new
UsersSelect
()
new
UsersSelect
()
...
@@ -35,39 +35,39 @@ class @IssuableForm
...
@@ -35,39 +35,39 @@ class @IssuableForm
@
descriptionField
.
data
(
"autosave"
).
reset
()
@
descriptionField
.
data
(
"autosave"
).
reset
()
initWip
:
->
initWip
:
->
return
unless
@
form
.
find
(
".js-wip-explanation"
).
length
@
$wipExplanation
=
@
form
.
find
(
".js-wip-explanation"
)
@
$noWipExplanation
=
@
form
.
find
(
".js-no-wip-explanation"
)
return
unless
@
$wipExplanation
.
length
and
@
$noWipExplanation
.
length
@
form
.
on
"click"
,
".js-
remove-wip"
,
@
remov
eWip
@
form
.
on
"click"
,
".js-
toggle-wip"
,
@
toggl
eWip
@
form
.
on
"click"
,
".js-add-wip"
,
@
addWip
@
titleField
.
on
"keyup blur"
,
@
renderWipExplanation
@
titleField
.
on
"change"
,
@
renderWipExplanation
@
renderWipExplanation
()
@
renderWipExplanation
()
workInProgress
:
->
workInProgress
:
->
@
titleField
.
val
().
match
(
@
wipRegex
)
@
wipRegex
.
test
@
titleField
.
val
(
)
renderWipExplanation
:
=>
renderWipExplanation
:
=>
if
@
workInProgress
()
if
@
workInProgress
()
@
form
.
find
(
".js-wip-explanation"
)
.
show
()
@
$wipExplanation
.
show
()
@
form
.
find
(
".js-no-wip-explanation"
)
.
hide
()
@
$noWipExplanation
.
hide
()
else
else
@
form
.
find
(
".js-wip-explanation"
)
.
hide
()
@
$wipExplanation
.
hide
()
@
form
.
find
(
".js-no-wip-explanation"
)
.
show
()
@
$noWipExplanation
.
show
()
remov
eWip
:
(
event
)
=>
toggl
eWip
:
(
event
)
=>
event
.
preventDefault
()
event
.
preventDefault
()
return
unless
@
workInProgress
()
if
@
workInProgress
()
@
titleField
.
val
@
titleField
.
val
().
replace
(
@
wipRegex
,
""
)
@
removeWip
()
else
@
addWip
()
@
renderWipExplanation
()
@
renderWipExplanation
()
addWip
:
(
event
)
=
>
removeWip
:
-
>
event
.
preventDefault
(
)
@
titleField
.
val
@
titleField
.
val
().
replace
(
@
wipRegex
,
""
)
return
if
@
workInProgress
()
addWip
:
->
@
titleField
.
val
"WIP:
#{
@
titleField
.
val
()
}
"
@
titleField
.
val
"WIP:
#{
@
titleField
.
val
()
}
"
@
renderWipExplanation
()
app/models/merge_request.rb
View file @
0b942541
...
@@ -259,7 +259,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -259,7 +259,7 @@ class MergeRequest < ActiveRecord::Base
self
.
target_project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
CLOSED
).
last
self
.
target_project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
CLOSED
).
last
end
end
WIP_REGEX
=
/\A\
[?WIP(\]|:| )
\s*/i
.
freeze
WIP_REGEX
=
/\A\
s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+
\s*/i
.
freeze
def
work_in_progress?
def
work_in_progress?
title
=~
WIP_REGEX
title
=~
WIP_REGEX
...
...
app/services/merge_requests/base_service.rb
View file @
0b942541
...
@@ -6,11 +6,8 @@ module MergeRequests
...
@@ -6,11 +6,8 @@ module MergeRequests
end
end
def
create_title_change_note
(
issuable
,
old_title
)
def
create_title_change_note
(
issuable
,
old_title
)
wipless_old_title
=
old_title
.
sub
(
MergeRequest
::
WIP_REGEX
,
""
)
removed_wip
=
old_title
=~
MergeRequest
::
WIP_REGEX
&&
!
issuable
.
work_in_progress?
wipless_new_title
=
issuable
.
title
.
sub
(
MergeRequest
::
WIP_REGEX
,
""
)
added_wip
=
old_title
!~
MergeRequest
::
WIP_REGEX
&&
issuable
.
work_in_progress?
removed_wip
=
wipless_old_title
==
issuable
.
title
added_wip
=
wipless_new_title
==
old_title
if
removed_wip
if
removed_wip
SystemNoteService
.
remove_merge_request_wip
(
issuable
,
issuable
.
project
,
current_user
)
SystemNoteService
.
remove_merge_request_wip
(
issuable
,
issuable
.
project
,
current_user
)
...
...
app/services/system_note_service.rb
View file @
0b942541
...
@@ -145,13 +145,13 @@ class SystemNoteService
...
@@ -145,13 +145,13 @@ class SystemNoteService
end
end
def
self
.
remove_merge_request_wip
(
noteable
,
project
,
author
)
def
self
.
remove_merge_request_wip
(
noteable
,
project
,
author
)
body
=
'Unmarked this merge request as Work In Progress'
body
=
'Unmarked this merge request as
a
Work In Progress'
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
end
def
self
.
add_merge_request_wip
(
noteable
,
project
,
author
)
def
self
.
add_merge_request_wip
(
noteable
,
project
,
author
)
body
=
'Marked this merge request as **Work In Progress**'
body
=
'Marked this merge request as
a
**Work In Progress**'
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
end
...
...
app/views/projects/merge_requests/widget/open/_wip.html.haml
View file @
0b942541
%h4
%h4
This merge request is currently a Work In Progress
This merge request is currently a Work In Progress
%p
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
%p
When this merge request is ready,
When this merge request is ready,
-
text
=
'remove the "WIP" prefix from the title'
=
link_to
remove_wip_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
method: :post
do
-
if
can?
(
current_user
,
:update_merge_request
,
@merge_request
)
remove the
=
link_to
text
,
remove_wip_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
method: :post
%code
WIP:
-
else
prefix from the title
=
text
to allow it to be merged.
to allow it to be merged.
app/views/shared/issuable/_form.html.haml
View file @
0b942541
...
@@ -14,15 +14,20 @@
...
@@ -14,15 +14,20 @@
-
if
issuable
.
is_a?
(
MergeRequest
)
-
if
issuable
.
is_a?
(
MergeRequest
)
%p
.help-block
%p
.help-block
.js-wip-explanation
.js-wip-explanation
%a
{
href:
"#"
,
class:
"js-remove-wip"
,
data:
{
}}
%a
.js-toggle-wip
{
href:
""
}
Remove the
<code>
WIP
</code>
prefix from the title
Remove the
%code
WIP:
prefix from the title
to allow this
to allow this
<strong>
Work In Progress
</strong>
merge request to be merged when it's ready.
%strong
Work In Progress
merge request to be merged when it's ready.
.js-no-wip-explanation
.js-no-wip-explanation
%a
{
href:
"#"
,
class:
"js-add-wip"
}
%a
.js-toggle-wip
{
href:
""
}
Start the title with
<code>
[WIP]
</code>
or
<code>
WIP:
</code>
Start the title with
%code
WIP:
to prevent a
to prevent a
<strong>
Work In Progress
</strong>
merge request from being merged before it's ready.
%strong
Work In Progress
merge request from being merged before it's ready.
.form-group.detail-page-description
.form-group.detail-page-description
=
f
.
label
:description
,
'Description'
,
class:
'control-label'
=
f
.
label
:description
,
'Description'
,
class:
'control-label'
.col-sm-10
.col-sm-10
...
...
spec/models/merge_request_spec.rb
View file @
0b942541
...
@@ -174,24 +174,11 @@ describe MergeRequest, models: true do
...
@@ -174,24 +174,11 @@ describe MergeRequest, models: true do
end
end
describe
"#work_in_progress?"
do
describe
"#work_in_progress?"
do
it
"detects the 'WIP ' prefix"
do
[
'WIP '
,
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
' [WIP] WIP [WIP] WIP: WIP '
].
each
do
|
wip_prefix
|
subject
.
title
=
"WIP
#{
subject
.
title
}
"
it
"detects the '
#{
wip_prefix
}
' prefix"
do
subject
.
title
=
"
#{
wip_prefix
}#{
subject
.
title
}
"
expect
(
subject
).
to
be_work_in_progress
expect
(
subject
).
to
be_work_in_progress
end
end
it
"detects the 'WIP: ' prefix"
do
subject
.
title
=
"WIP:
#{
subject
.
title
}
"
expect
(
subject
).
to
be_work_in_progress
end
it
"detects the '[WIP] ' prefix"
do
subject
.
title
=
"[WIP]
#{
subject
.
title
}
"
expect
(
subject
).
to
be_work_in_progress
end
it
"detects the '[WIP]' prefix"
do
subject
.
title
=
"[WIP]
#{
subject
.
title
}
"
expect
(
subject
).
to
be_work_in_progress
end
end
it
"doesn't detect WIP for words starting with WIP"
do
it
"doesn't detect WIP for words starting with WIP"
do
...
@@ -199,6 +186,11 @@ describe MergeRequest, models: true do
...
@@ -199,6 +186,11 @@ describe MergeRequest, models: true do
expect
(
subject
).
not_to
be_work_in_progress
expect
(
subject
).
not_to
be_work_in_progress
end
end
it
"doesn't detect WIP for words containing with WIP"
do
subject
.
title
=
"WupWipwap
#{
subject
.
title
}
"
expect
(
subject
).
not_to
be_work_in_progress
end
it
"doesn't detect WIP by default"
do
it
"doesn't detect WIP by default"
do
expect
(
subject
).
not_to
be_work_in_progress
expect
(
subject
).
not_to
be_work_in_progress
end
end
...
...
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