Skip to content

Commit f2004e2

Browse files
committed
Do not cache regex after first use
The /o flag tells Ruby to only interpolate the regex once, cache the result of that interpolation, and use it for the rest of the life of the project. Effectively, it in-lines the result of the first time you interpolate. This is a Bad Time™️ for us because that means we cache the first story number we try. In most production usages this is fine b/c we fire up the Ruby process and only check a single time. But that's not true for tests, so depending on the order tests are run, they could start breaking! No more!
1 parent 268a825 commit f2004e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/git_tracker/commit_message.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def initialize(file)
66
end
77

88
def mentions_story?(number)
9-
@message =~ /^(?!#).*\[(\w+\s)?(#\d+\s)*##{number}(\s#\d+)*(\s\w+)?\]/io
9+
@message =~ /^(?!#).*\[(\w+\s)?(#\d+\s)*##{number}(\s#\d+)*(\s\w+)?\]/i
1010
end
1111

1212
def keyword

0 commit comments

Comments
 (0)