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
1721bbcb
Commit
1721bbcb
authored
Jun 13, 2018
by
Jan
Committed by
Rémy Coutable
Jun 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Quick actions are case sensitive"
parent
df2efbdb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
changelogs/unreleased/47050-quick-actions-case-insensitive.yml
...elogs/unreleased/47050-quick-actions-case-insensitive.yml
+5
-0
lib/gitlab/quick_actions/extractor.rb
lib/gitlab/quick_actions/extractor.rb
+4
-4
lib/gitlab/quick_actions/substitution_definition.rb
lib/gitlab/quick_actions/substitution_definition.rb
+1
-1
spec/lib/gitlab/quick_actions/extractor_spec.rb
spec/lib/gitlab/quick_actions/extractor_spec.rb
+16
-0
No files found.
changelogs/unreleased/47050-quick-actions-case-insensitive.yml
0 → 100644
View file @
1721bbcb
---
title
:
Make quick commands case insensitive
merge_request
:
19614
author
:
Jan Beckmann
type
:
fixed
lib/gitlab/quick_actions/extractor.rb
View file @
1721bbcb
...
...
@@ -39,7 +39,7 @@ module Gitlab
content
.
delete!
(
"
\r
"
)
content
.
gsub!
(
commands_regex
)
do
if
$~
[
:cmd
]
commands
<<
[
$~
[
:cmd
],
$~
[
:arg
]].
reject
(
&
:blank?
)
commands
<<
[
$~
[
:cmd
]
.
downcase
,
$~
[
:arg
]].
reject
(
&
:blank?
)
''
else
$~
[
0
]
...
...
@@ -102,14 +102,14 @@ module Gitlab
# /close
^
\/
(?<cmd>
#{
Regexp
.
union
(
names
)
}
)
(?<cmd>
#{
Regexp
.
new
(
Regexp
.
union
(
names
).
source
,
Regexp
::
IGNORECASE
)
}
)
(?:
[ ]
(?<arg>[^
\n
]*)
)?
(?:
\n
|$)
)
}mx
}m
i
x
end
def
perform_substitutions
(
content
,
commands
)
...
...
@@ -120,7 +120,7 @@ module Gitlab
end
substitution_definitions
.
each
do
|
substitution
|
match_data
=
substitution
.
match
(
content
)
match_data
=
substitution
.
match
(
content
.
downcase
)
if
match_data
command
=
[
substitution
.
name
.
to_s
]
command
<<
match_data
[
1
]
unless
match_data
[
1
].
empty?
...
...
lib/gitlab/quick_actions/substitution_definition.rb
View file @
1721bbcb
...
...
@@ -15,7 +15,7 @@ module Gitlab
return
unless
content
all_names
.
each
do
|
a_name
|
content
.
gsub!
(
%r{/
#{
a_name
}
?(.*)$}
,
execute_block
(
action_block
,
context
,
'\1'
))
content
.
gsub!
(
%r{/
#{
a_name
}
?(.*)$}
i
,
execute_block
(
action_block
,
context
,
'\1'
))
end
content
end
...
...
spec/lib/gitlab/quick_actions/extractor_spec.rb
View file @
1721bbcb
...
...
@@ -182,6 +182,14 @@ describe Gitlab::QuickActions::Extractor do
expect
(
msg
).
to
eq
"hello
\n
world"
end
it
'extracts command case insensitive'
do
msg
=
%(hello\n/PoWer @user.name %9.10 ~"bar baz.2"\nworld)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
expect
(
commands
).
to
eq
[[
'power'
,
'@user.name %9.10 ~"bar baz.2"'
]]
expect
(
msg
).
to
eq
"hello
\n
world"
end
it
'does not extract noop commands'
do
msg
=
%(hello\nworld\n/reopen\n/noop_command)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
...
...
@@ -206,6 +214,14 @@ describe Gitlab::QuickActions::Extractor do
expect
(
msg
).
to
eq
"hello
\n
world
\n
this is great? SHRUG"
end
it
'extracts and performs substitution commands case insensitive'
do
msg
=
%(hello\nworld\n/reOpen\n/sHRuG this is great?)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
expect
(
commands
).
to
eq
[[
'reopen'
],
[
'shrug'
,
'this is great?'
]]
expect
(
msg
).
to
eq
"hello
\n
world
\n
this is great? SHRUG"
end
it
'extracts and performs substitution commands with comments'
do
msg
=
%(hello\nworld\n/reopen\n/substitution wow this is a thing.)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
...
...
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