unsplash / comment-on-pr

A GitHub Action to comment on the relevant open PR when a commit is pushed.
MIT License
150 stars 84 forks source link

Fix pattern based options #44

Closed jeffreyguenther closed 2 years ago

jeffreyguenther commented 3 years ago

In this PR, I fix a bug that's present in the action currently:

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.

In irb, you can check the following:

irb(main):024:1* if ""
irb(main):025:1*   puts "that string was truthy"
irb(main):026:0> end
(irb):26: warning: string literal in condition
that string was truthy
=> nil
irb(main):027:1* if "nil"
irb(main):028:1*   puts "that string was truthy"
irb(main):029:0> end
(irb):29: warning: string literal in condition
that string was truthy
=> nil
irb(main):030:1* if false
irb(main):031:1*   puts "that string was truthy"
irb(main):032:0> end
=> nil

In addition, I do some other clean up - make the option descriptions more consistent and restore an optimization that was recently removed.

jeffreyguenther commented 3 years ago

@aaronklaassen for your attention.

wong2 commented 2 years ago

@aaronklaassen plz merge this, the action is broken now