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

Commit

Permalink
Merge pull request #1823 from Shopify/git-available-fix
Browse files Browse the repository at this point in the history
Indicate git is unavailable; don't error out
  • Loading branch information
amcaplan authored Dec 6, 2021
2 parents bb3f891 + 5e7a700 commit a6ed2e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
## [Unreleased]

### Fixed
* [#1823](https://github.com/Shopify/shopify-cli/pull/1823): Indicate git is unavailable; don't error out
* [#1807](https://github.com/Shopify/shopify-cli/pull/1807): Fix `--live` parameter, it should not imply `--allow-live` in the `theme push` command
* [#1812](https://github.com/Shopify/shopify-cli/pull/1812): App creation with Rails 7
## Version 2.7.2
Expand Down
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

0 comments on commit a6ed2e9

Please sign in to comment.