From 819a35dede5e78a43b23bcc553f6663560769ffe Mon Sep 17 00:00:00 2001 From: Richard Clamp Date: Wed, 14 Mar 2018 10:54:49 +0000 Subject: [PATCH] Allow options to be specified to git_cmd Allows, for example, the commit message to be more interestingly generated. Signed-off-by: Richard Clamp --- lib/omnibus/git_cache.rb | 4 ++-- spec/unit/git_cache_spec.rb | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/omnibus/git_cache.rb b/lib/omnibus/git_cache.rb index 513f8134e..c4c33272c 100644 --- a/lib/omnibus/git_cache.rb +++ b/lib/omnibus/git_cache.rb @@ -195,7 +195,7 @@ def remove_git_dirs # # @return [Mixlib::Shellout] the underlying command object. # - def git_cmd(command) + def git_cmd(command, opts = {}) shellout!([ "git", "-c core.autocrlf=false", @@ -203,7 +203,7 @@ def git_cmd(command) "--git-dir=\"#{cache_path}\"", "--work-tree=\"#{install_dir}\"", command, - ].join(" ")) + ].join(" "), opts) end # diff --git a/spec/unit/git_cache_spec.rb b/spec/unit/git_cache_spec.rb index c97cbc56b..0d188fd55 100644 --- a/spec/unit/git_cache_spec.rb +++ b/spec/unit/git_cache_spec.rb @@ -244,16 +244,22 @@ module Omnibus allow(project).to receive(:install_dir) .and_return(terrible_install_dir) allow(ipc).to receive(:shellout!) - .with(%Q{git #{git_flags} version}) + .with(%Q{git #{git_flags} version}, {}) .and_return("git version 2.11.0") end it "doesn't mangle an #install_dir with spaces" do expect(ipc.send(:install_dir)).to eq(terrible_install_dir) expect(ipc).to receive(:shellout!) - .with(%Q{git #{git_flags} version}) + .with(%Q{git #{git_flags} version}, {}) ipc.send(:git_cmd, "version") end + + it "passes options" do + expect(ipc).to receive(:shellout!) + .with(%Q{git #{git_flags} commit -F -}, input: "Commit message") + ipc.send(:git_cmd, "commit -F -", input: "Commit message") + end end end end