Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Indicate git is unavailable; don't error out #1823

Merged
merged 2 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/shopify_cli/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class << self
def available?(ctx)
_output, status = ctx.capture2e("git", "status")
status.success?
rescue Errno::ENOENT # git is not installed
false
end

##
Expand Down
8 changes: 8 additions & 0 deletions test/shopify-cli/git_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def test_available_returns_false_if_git_not_available
refute(ShopifyCLI::Git.available?(@context))
end

def test_available_returns_false_if_git_not_available_and_raises
@context.expects(:capture2e)
.with("git", "status")
.raises(Errno::ENOENT, "No such file or directory - git")

refute(ShopifyCLI::Git.available?(@context))
end

def test_branches_returns_master_if_no_branches_exist
@context.expects(:capture2e)
.with("git", "branch", "--list", "--format=%(refname:short)")
Expand Down