From cf5c7dcaf1061268ab2434f05ea767f0458e9ff5 Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Wed, 15 Mar 2017 15:44:28 -0400 Subject: [PATCH] Fix up Regexp creation for Ruby >= 2.2 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 --- lib/github-release.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/github-release.rb b/lib/github-release.rb index 429f8b8..0faf080 100644 --- a/lib/github-release.rb +++ b/lib/github-release.rb @@ -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