Skip to content

Commit

Permalink
Allow options to be specified to git_cmd
Browse files Browse the repository at this point in the history
Allows, for example, the commit message to be more interestingly
generated.

Signed-off-by: Richard Clamp <[email protected]>
  • Loading branch information
richardc committed Mar 14, 2018
1 parent b295322 commit 819a35d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/omnibus/git_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ 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",
"-c core.ignorecase=false",
"--git-dir=\"#{cache_path}\"",
"--work-tree=\"#{install_dir}\"",
command,
].join(" "))
].join(" "), opts)
end

#
Expand Down
10 changes: 8 additions & 2 deletions spec/unit/git_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 819a35d

Please sign in to comment.