forked from berkshelf/berkshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract git mixin into its own module
Fixes berkshelf#1208
- Loading branch information
Showing
7 changed files
with
66 additions
and
50 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'buff/shell_out' | ||
|
||
module Berkshelf | ||
module Mixin | ||
module Git | ||
# Perform a git command. | ||
# | ||
# @param [String] command | ||
# the command to run | ||
# @param [Boolean] error | ||
# whether to raise error if the command fails | ||
# | ||
# @raise [String] | ||
# the +$stdout+ from the command | ||
def git(command, error = true) | ||
unless Berkshelf.which('git') || Berkshelf.which('git.exe') | ||
raise GitNotInstalled.new | ||
end | ||
|
||
response = Buff::ShellOut.shell_out(%|git #{command}|) | ||
|
||
if error && !response.success? | ||
raise GitCommandError.new(command, cache_path, response.stderr) | ||
end | ||
|
||
response.stdout.strip | ||
end | ||
end | ||
end | ||
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