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
8f424be7
Commit
8f424be7
authored
Oct 13, 2021
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align front/backend Draft MR regexes
parent
98332bab
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
25 deletions
+14
-25
app/assets/javascripts/issuable_form.js
app/assets/javascripts/issuable_form.js
+0
-4
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+1
-1
spec/frontend/issuable_form_spec.js
spec/frontend/issuable_form_spec.js
+1
-4
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+7
-11
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+5
-5
No files found.
app/assets/javascripts/issuable_form.js
View file @
8f424be7
...
@@ -50,20 +50,16 @@ export default class IssuableForm {
...
@@ -50,20 +50,16 @@ export default class IssuableForm {
this
.
renderWipExplanation
=
this
.
renderWipExplanation
.
bind
(
this
);
this
.
renderWipExplanation
=
this
.
renderWipExplanation
.
bind
(
this
);
this
.
resetAutosave
=
this
.
resetAutosave
.
bind
(
this
);
this
.
resetAutosave
=
this
.
resetAutosave
.
bind
(
this
);
this
.
handleSubmit
=
this
.
handleSubmit
.
bind
(
this
);
this
.
handleSubmit
=
this
.
handleSubmit
.
bind
(
this
);
/* eslint-disable @gitlab/require-i18n-strings */
// prettier-ignore
// prettier-ignore
this
.
draftRegex
=
new
RegExp
(
this
.
draftRegex
=
new
RegExp
(
'
^
\\
s*(
'
+
// Line start, then any amount of leading whitespace
'
^
\\
s*(
'
+
// Line start, then any amount of leading whitespace
'
draft
\\
s-
\\
s
'
+
// Draft_-_ where "_" are *exactly* one whitespace
'
|
\\
[draft
\\
]
\\
s*
'
+
// [Draft] and any following whitespace
'
|
\\
[draft
\\
]
\\
s*
'
+
// [Draft] and any following whitespace
'
|draft:
\\
s*
'
+
// Draft: and any following whitespace
'
|draft:
\\
s*
'
+
// Draft: and any following whitespace
'
|draft
\\
s+
'
+
// Draft_ where "_" is at least one whitespace
'
|
\\
(draft
\\
)
\\
s*
'
+
// (Draft) and any following whitespace
'
|
\\
(draft
\\
)
\\
s*
'
+
// (Draft) and any following whitespace
'
)+
'
+
// At least one repeated match of the preceding parenthetical
'
)+
'
+
// At least one repeated match of the preceding parenthetical
'
\\
s*
'
,
// Any amount of trailing whitespace
'
\\
s*
'
,
// Any amount of trailing whitespace
'
i
'
,
// Match any case(s)
'
i
'
,
// Match any case(s)
);
);
/* eslint-enable @gitlab/require-i18n-strings */
this
.
gfmAutoComplete
=
new
GfmAutoComplete
(
this
.
gfmAutoComplete
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
,
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
,
...
...
lib/gitlab/regex.rb
View file @
8f424be7
...
@@ -409,7 +409,7 @@ module Gitlab
...
@@ -409,7 +409,7 @@ module Gitlab
end
end
def
merge_request_draft
def
merge_request_draft
/\A(?i)(\[draft\]|\(draft\)|draft:
|draft\s\-\s|draft\z
)/
/\A(?i)(\[draft\]|\(draft\)|draft:)/
end
end
def
issue
def
issue
...
...
spec/frontend/issuable_form_spec.js
View file @
8f424be7
...
@@ -20,16 +20,13 @@ describe('IssuableForm', () => {
...
@@ -20,16 +20,13 @@ describe('IssuableForm', () => {
describe
(
'
removeWip
'
,
()
=>
{
describe
(
'
removeWip
'
,
()
=>
{
it
.
each
`
it
.
each
`
prefix
prefix
${
'
drAft
'
}
${
'
draFT:
'
}
${
'
draFT:
'
}
${
'
[DRaft]
'
}
${
'
[DRaft]
'
}
${
'
drAft:
'
}
${
'
drAft:
'
}
${
'
[draFT]
'
}
${
'
[draFT]
'
}
${
'
dRaFt -
'
}
${
'
dRaFt -
'
}
${
'
(draft)
'
}
${
'
(draft)
'
}
${
'
(DrafT)
'
}
${
'
(DrafT)
'
}
${
'
draft
draft - draft
: [draft] (draft)
'
}
${
'
draft: [draft] (draft)
'
}
`
(
'
removes "$prefix" from the beginning of the title
'
,
({
prefix
})
=>
{
`
(
'
removes "$prefix" from the beginning of the title
'
,
({
prefix
})
=>
{
instance
.
titleField
.
val
(
`
${
prefix
}
The Issuable's Title Value`
);
instance
.
titleField
.
val
(
`
${
prefix
}
The Issuable's Title Value`
);
...
...
spec/models/commit_spec.rb
View file @
8f424be7
...
@@ -799,7 +799,7 @@ eos
...
@@ -799,7 +799,7 @@ eos
describe
'#work_in_progress?'
do
describe
'#work_in_progress?'
do
[
[
'squash! '
,
'fixup! '
,
'wip: '
,
'WIP: '
,
'[WIP] '
,
'squash! '
,
'fixup! '
,
'wip: '
,
'WIP: '
,
'[WIP] '
,
'draft: '
,
'
Draft - '
,
'
[Draft] '
,
'(draft) '
,
'Draft: '
'draft: '
,
'[Draft] '
,
'(draft) '
,
'Draft: '
].
each
do
|
wip_prefix
|
].
each
do
|
wip_prefix
|
it
"detects the '
#{
wip_prefix
}
' prefix"
do
it
"detects the '
#{
wip_prefix
}
' prefix"
do
commit
.
message
=
"
#{
wip_prefix
}#{
commit
.
message
}
"
commit
.
message
=
"
#{
wip_prefix
}#{
commit
.
message
}
"
...
@@ -814,24 +814,20 @@ eos
...
@@ -814,24 +814,20 @@ eos
expect
(
commit
).
to
be_work_in_progress
expect
(
commit
).
to
be_work_in_progress
end
end
it
"d
etects
WIP for a commit just saying 'draft'"
do
it
"d
oes not detect
WIP for a commit just saying 'draft'"
do
commit
.
message
=
"draft"
commit
.
message
=
"draft"
expect
(
commit
).
to
be_work_in_progress
end
it
"doesn't detect WIP for a commit that begins with 'FIXUP! '"
do
commit
.
message
=
"FIXUP!
#{
commit
.
message
}
"
expect
(
commit
).
not_to
be_work_in_progress
expect
(
commit
).
not_to
be_work_in_progress
end
end
it
"doesn't detect WIP for words starting with WIP"
do
[
"FIXUP!"
,
"Draft - "
,
"Wipeout"
].
each
do
|
draft_prefix
|
commit
.
message
=
"Wipout
#{
commit
.
message
}
"
it
"doesn't detect '
#{
draft_prefix
}
' at the start of the title as a draft"
do
commit
.
message
=
"
#{
draft_prefix
}
#{
commit
.
message
}
"
expect
(
commit
).
not_to
be_work_in_progress
expect
(
commit
).
not_to
be_work_in_progress
end
end
end
end
end
describe
'.valid_hash?'
do
describe
'.valid_hash?'
do
it
'checks hash contents'
do
it
'checks hash contents'
do
...
...
spec/models/merge_request_spec.rb
View file @
8f424be7
...
@@ -1348,7 +1348,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
...
@@ -1348,7 +1348,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
[
[
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
' [WIP] WIP: [WIP] WIP:'
,
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
' [WIP] WIP: [WIP] WIP:'
,
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
,
'Draft - '
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
].
each
do
|
wip_prefix
|
].
each
do
|
wip_prefix
|
it
"detects the '
#{
wip_prefix
}
' prefix"
do
it
"detects the '
#{
wip_prefix
}
' prefix"
do
subject
.
title
=
"
#{
wip_prefix
}#{
subject
.
title
}
"
subject
.
title
=
"
#{
wip_prefix
}#{
subject
.
title
}
"
...
@@ -1359,7 +1359,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
...
@@ -1359,7 +1359,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
[
[
"WIP "
,
"(WIP)"
,
"WIP "
,
"(WIP)"
,
"draft"
,
"Draft"
"draft"
,
"Draft"
,
"Draft -"
,
"draft - "
,
"Draft "
,
"draft "
].
each
do
|
draft_prefix
|
].
each
do
|
draft_prefix
|
it
"doesn't detect '
#{
draft_prefix
}
' at the start of the title as a draft"
do
it
"doesn't detect '
#{
draft_prefix
}
' at the start of the title as a draft"
do
subject
.
title
=
"
#{
draft_prefix
}#{
subject
.
title
}
"
subject
.
title
=
"
#{
draft_prefix
}#{
subject
.
title
}
"
...
@@ -1374,10 +1374,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
...
@@ -1374,10 +1374,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect
(
subject
.
work_in_progress?
).
to
eq
true
expect
(
subject
.
work_in_progress?
).
to
eq
true
end
end
it
"d
etects
merge request title just saying 'draft'"
do
it
"d
oes not detect
merge request title just saying 'draft'"
do
subject
.
title
=
"draft"
subject
.
title
=
"draft"
expect
(
subject
.
work_in_progress?
).
to
eq
tru
e
expect
(
subject
.
work_in_progress?
).
to
eq
fals
e
end
end
it
'does not detect WIP in the middle of the title'
do
it
'does not detect WIP in the middle of the title'
do
...
@@ -1439,7 +1439,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
...
@@ -1439,7 +1439,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
[
[
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
'[WIP] WIP: [WIP] WIP:'
,
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
'[WIP] WIP: [WIP] WIP:'
,
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
,
'Draft - '
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
].
each
do
|
wip_prefix
|
].
each
do
|
wip_prefix
|
it
"removes the '
#{
wip_prefix
}
' prefix"
do
it
"removes the '
#{
wip_prefix
}
' prefix"
do
wipless_title
=
subject
.
title
wipless_title
=
subject
.
title
...
...
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