-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 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
- Loading branch information
Showing
4 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Hatchet | ||
VERSION = "7.4.0" | ||
VERSION = "8.0.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
require "spec_helper" | ||
|
||
describe "DefaultCIBranch" do | ||
it "doesn't error on empty env" do | ||
out = DefaultCIBranch.new(env: {}).call | ||
expect(out).to be_nil | ||
end | ||
|
||
it "GitHub PRs" do | ||
out = DefaultCIBranch.new(env: {"GITHUB_HEAD_REF" => "iAmaPR"}).call | ||
expect(out).to eq("iAmaPR") | ||
|
||
out = DefaultCIBranch.new(env: {"GITHUB_HEAD_REF" => ""}).call | ||
expect(out).to be_nil | ||
end | ||
|
||
it "GitHub branches" do | ||
out = DefaultCIBranch.new(env: {"GITHUB_REF_NAME" => "iAmaBranch"}).call | ||
expect(out).to eq("iAmaBranch") | ||
end | ||
|
||
it "heroku" do | ||
out = DefaultCIBranch.new(env: {"HEROKU_TEST_RUN_BRANCH" => "iAmaBranch"}).call | ||
expect(out).to eq("iAmaBranch") | ||
end | ||
end |