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 {
this
.
renderWipExplanation
=
this
.
renderWipExplanation
.
bind
(
this
);
this
.
resetAutosave
=
this
.
resetAutosave
.
bind
(
this
);
this
.
handleSubmit
=
this
.
handleSubmit
.
bind
(
this
);
/* eslint-disable @gitlab/require-i18n-strings */
// prettier-ignore
this
.
draftRegex
=
new
RegExp
(
'
^
\\
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_ where "_" is at least one whitespace
'
|
\\
(draft
\\
)
\\
s*
'
+
// (Draft) and any following whitespace
'
)+
'
+
// At least one repeated match of the preceding parenthetical
'
\\
s*
'
,
// Any amount of trailing whitespace
'
i
'
,
// Match any case(s)
);
/* eslint-enable @gitlab/require-i18n-strings */
this
.
gfmAutoComplete
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
,
...
...
lib/gitlab/regex.rb
View file @
8f424be7
...
...
@@ -409,7 +409,7 @@ module Gitlab
end
def
merge_request_draft
/\A(?i)(\[draft\]|\(draft\)|draft:
|draft\s\-\s|draft\z
)/
/\A(?i)(\[draft\]|\(draft\)|draft:)/
end
def
issue
...
...
spec/frontend/issuable_form_spec.js
View file @
8f424be7
...
...
@@ -20,16 +20,13 @@ describe('IssuableForm', () => {
describe
(
'
removeWip
'
,
()
=>
{
it
.
each
`
prefix
${
'
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
})
=>
{
instance
.
titleField
.
val
(
`
${
prefix
}
The Issuable's Title Value`
);
...
...
spec/models/commit_spec.rb
View file @
8f424be7
...
...
@@ -799,7 +799,7 @@ eos
describe
'#work_in_progress?'
do
[
'squash! '
,
'fixup! '
,
'wip: '
,
'WIP: '
,
'[WIP] '
,
'draft: '
,
'
Draft - '
,
'
[Draft] '
,
'(draft) '
,
'Draft: '
'draft: '
,
'[Draft] '
,
'(draft) '
,
'Draft: '
].
each
do
|
wip_prefix
|
it
"detects the '
#{
wip_prefix
}
' prefix"
do
commit
.
message
=
"
#{
wip_prefix
}#{
commit
.
message
}
"
...
...
@@ -814,24 +814,20 @@ eos
expect
(
commit
).
to
be_work_in_progress
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"
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
end
it
"doesn't detect WIP for words starting with WIP"
do
commit
.
message
=
"Wipout
#{
commit
.
message
}
"
[
"FIXUP!"
,
"Draft - "
,
"Wipeout"
].
each
do
|
draft_prefix
|
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
end
end
end
describe
'.valid_hash?'
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
[
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
' [WIP] WIP: [WIP] WIP:'
,
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
,
'Draft - '
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
].
each
do
|
wip_prefix
|
it
"detects the '
#{
wip_prefix
}
' prefix"
do
subject
.
title
=
"
#{
wip_prefix
}#{
subject
.
title
}
"
...
...
@@ -1359,7 +1359,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
[
"WIP "
,
"(WIP)"
,
"draft"
,
"Draft"
"draft"
,
"Draft"
,
"Draft -"
,
"draft - "
,
"Draft "
,
"draft "
].
each
do
|
draft_prefix
|
it
"doesn't detect '
#{
draft_prefix
}
' at the start of the title as a draft"
do
subject
.
title
=
"
#{
draft_prefix
}#{
subject
.
title
}
"
...
...
@@ -1374,10 +1374,10 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect
(
subject
.
work_in_progress?
).
to
eq
true
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"
expect
(
subject
.
work_in_progress?
).
to
eq
tru
e
expect
(
subject
.
work_in_progress?
).
to
eq
fals
e
end
it
'does not detect WIP in the middle of the title'
do
...
...
@@ -1439,7 +1439,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
[
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
'[WIP] WIP: [WIP] WIP:'
,
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
,
'Draft - '
'draft:'
,
'Draft: '
,
'[Draft]'
,
'[DRAFT] '
].
each
do
|
wip_prefix
|
it
"removes the '
#{
wip_prefix
}
' prefix"
do
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