summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejandroluis24@gmail.com>2016-04-05 21:35:43 -0300
committerAlejandro Rodríguez <alejandroluis24@gmail.com>2016-04-20 22:12:43 -0300
commit0ba116a58ed57d760b264c39f241798528f54b0e (patch)
tree0636bb65310246ab631cb02c2036f1491dd1f031
parent4cab66e3e2ca53c2d96a5306b6ae6cd864c5a39d (diff)
downloadgitlab-ce-0ba116a58ed57d760b264c39f241798528f54b0e.tar.gz
Matching version-like expressions as `milestone_name`s instead of `milestone_iid`s
The changes also account for %2.1. being matched as milestone_name = "2.1" without the word-separating dot.
-rw-r--r--app/models/milestone.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 50fa95d4d4b..92c07fd20da 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -79,14 +79,19 @@ class Milestone < ActiveRecord::Base
end
def self.reference_pattern
+ # NOTE: The iid pattern only matches when all characters on the expression
+ # are digits, so it will match %2 but not %2.1 because that's probably a
+ # milestone name and we want it to be matched as such.
%r{
(#{Project.reference_pattern})?
#{Regexp.escape(reference_prefix)}
(?:
- (?<milestone_iid>\d+) | # Integer-based milestone iid, or
+ (?<milestone_iid>
+ \d+(?!\S\w)\b # Integer-based milestone iid, or
+ ) |
(?<milestone_name>
- [A-Za-z0-9_-]+ | # String-based single-word milestone title, or
- "[^"]+" # String-based multi-word milestone surrounded in quotes
+ [^"\s]+\b | # String-based single-word milestone title, or
+ "[^"]+" # String-based multi-word milestone surrounded in quotes
)
)
}x