mirror of
https://github.com/unsplash/comment-on-pr.git
synced 2024-09-20 07:36:02 +08:00
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:
parent
8c517e3fa6
commit
d728af3ba7
|
@ -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"])
|
||||
|
|
Loading…
Reference in a new issue