Skip to content

Commit

Permalink
Fix up Regexp creation for Ruby >= 2.2
Browse files Browse the repository at this point in the history
Regular expressions and grep were changed somewhere around Ruby 2.2 and
it is no longer possible to simply read a string in from the config file
and use it as a regular expression.  You must now read it in, if it
isn't empty, then you must convert it from a string to a regular
expression, and only then can it be used by the grep calls elsewhere.
This fixes the problem where valid grep strings in the config file
failed to result in grep matches.

Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
dledford committed Mar 25, 2017
1 parent 5912aea commit cf5c7dc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/github-release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ def get_new_token
end

def pre_regex
@pre_regex ||= `git config --get release.pre-regex`.strip
@pre_regex = /^v\d+\.\d+(\.\d+)?(-rc\d+.*){1}$/ if @pre_regex.empty?
config_entry = `git config --get release.pre-regex`.strip
@pre_regex = /#{config_entry}/ if !config_entry.empty?
@pre_regex ||= /^v\d+\.\d+(\.\d+)?(-rc\d+.*){1}$/
log_val(@pre_regex)
end

def tag_regex
@tag_regex ||= `git config --get release.tag-regex`.strip
@tag_regex = /^v\d+\.\d+(\.\d+)?$/ if @tag_regex.empty?
config_entry = `git config --get release.tag-regex`.strip
@tag_regex = /#{config_entry}/ if !config_entry.empty?
@tag_regex ||= /^v\d+\.\d+(\.\d+)?$/
log_val(@tag_regex)
end

Expand Down

0 comments on commit cf5c7dc

Please sign in to comment.