Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on main #196

Closed
schneems opened this issue Feb 21, 2023 · 0 comments · Fixed by #197
Closed

Error on main #196

schneems opened this issue Feb 21, 2023 · 0 comments · Fixed by #197

Comments

@schneems
Copy link
Contributor

The env can be nil or an empty string introduced in a9d3dc5

     NoMethodError:
       undefined method `empty?' for nil:NilClass

           return ENV['GITHUB_HEAD_REF'] if !ENV['GITHUB_HEAD_REF'].empty?
                                                                   ^^^^^^^

We can fix with the lonely operator.

schneems added a commit that referenced this issue Feb 27, 2023
* Fix bug #196

The call to `empty?` will fail if the key GITHUB_HEAD_REF does not exist.

Before fixing this problem, I extracted the logic to its own testable class. Then I added tests, which also showed that `GITHUB_REF_NAME` would never be returned either (a previously unknown bug) because `!@env["GITHUB_HEAD_REF"]&.empty?` will always be truthy unless the key exists and it's empty.

This would (possibly) be cleaner with pattern matching. Ruby has pattern matching but we can't use it yet due to minimum supported Ruby version https://docs.ruby-lang.org/en/3.0/syntax/pattern_matching_rdoc.html.

Close #196

* v8.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant