From fb0a8989dbc2b3ec4983804fc2e4c5bdbebf5e36 Mon Sep 17 00:00:00 2001 From: James Stocks Date: Wed, 25 Jul 2018 20:57:03 +0100 Subject: [PATCH] Add extra fault checking to git fetcher (#3239) Raise with the stderr from `git ls-remote` if stderr is not empty. This is useful when inspec runs in CI and you do not have direct control/troublshooting options. Signed-off-by: James Stocks --- lib/fetchers/git.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/fetchers/git.rb b/lib/fetchers/git.rb index c3b539f26..05ea70ae5 100644 --- a/lib/fetchers/git.rb +++ b/lib/fetchers/git.rb @@ -83,7 +83,9 @@ module Fetchers end def resolve_ref(ref_name) - cmd = shellout("git ls-remote \"#{@remote_url}\" \"#{ref_name}*\"") + command_string = "git ls-remote \"#{@remote_url}\" \"#{ref_name}*\"" + cmd = shellout(command_string) + raise "Error running '#{command_string}': #{cmd.stderr}" unless cmd.stderr == '' ref = parse_ls_remote(cmd.stdout, ref_name) if !ref raise "Unable to resolve #{ref_name} to a specific git commit for #{@remote_url}"