Check for empty strings rather than falsey values

In Ruby, an empty string is truthy. As a result, passed a value of "" or
"nil", these branches of the code will run.

As a result, we need to change the default values of the input to `""`
and check if the passed value is an empty string.

No parsing is done to the values passed in as args so these are just
strings. `"nil"` doesn't become `nil` and is truthy.
This commit is contained in:
Jeffrey Guenther 2021-10-01 17:15:19 -07:00
parent 8c517e3fa6
commit d728af3ba7

View file

@ -43,8 +43,7 @@ end
comments = github.issue_comments(repo, pr_number)
if check_duplicate_msg == "true"
duplicate = if duplicate_msg_pattern
comments.find { |c| c["body"] =~ Regexp.new(duplicate_msg_pattern) }
duplicate = if !duplicate_msg_pattern.empty?
else
comments.find { |c| c["body"] == message }
end
@ -55,7 +54,7 @@ if check_duplicate_msg == "true"
end
end
if delete_prev_regex_msg
if !delete_prev_regex_msg.empty?
comments.each do |comment|
if comment["body"].match(/#{delete_prev_regex_msg}/)
github.delete_comment(repo, comment["id"])