From d728af3ba79acece5817bb627aab27571ded96cb Mon Sep 17 00:00:00 2001 From: Jeffrey Guenther Date: Fri, 1 Oct 2021 17:15:19 -0700 Subject: [PATCH] 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. --- entrypoint.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index bb11f74..8123d72 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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"])