Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run commands as array instead of string concat #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/chef_diff/repo/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def exists?
return false
else
cmd = Mixlib::ShellOut.new(
"#{@bin} status",
[@bin, 'status'],
cwd: File.expand_path(@repo_path)
)
cmd.run_command
Expand All @@ -48,7 +48,7 @@ def exists?

def head_rev
cmd = Mixlib::ShellOut.new(
"#{@bin} log -n 1 --pretty=format:'%H'",
[@bin, 'log', '-n', '1', "--pretty=format:'%H'"],
cwd: File.expand_path(@repo_path)
)
stdout = exec_cmd(cmd, 'Failed get git repo head ref')
Expand All @@ -57,7 +57,7 @@ def head_rev

def checkout(url)
s = Mixlib::ShellOut.new(
"#{@bin} clone --depth 1 #{url} #{@repo_path}"
[@bin, 'clone', '--depth', '1', url, @repo_path]
).run_command
s.error!
@repo = @repo_path
Expand All @@ -67,7 +67,7 @@ def checkout(url)
def changes(start_ref, end_ref)
check_refs(start_ref, end_ref)
s = Mixlib::ShellOut.new(
"#{@bin} diff --name-status #{start_ref} #{end_ref}",
[@bin, 'diff', '--name-status', start_ref, end_ref],
cwd: File.expand_path(@repo_path)
)
s.run_command.error!
Expand Down Expand Up @@ -103,7 +103,7 @@ def update
# Return all files
def files
cmd = Mixlib::ShellOut.new(
"#{@bin} ls-files -v .",
[@bin, 'ls-files', '-v', '.'],
cwd: File.expand_path(@repo_path)
)
stdout = exec_cmd(cmd, 'Failed get git repo files')
Expand Down Expand Up @@ -138,7 +138,7 @@ def check_refs(start_ref, end_ref)

def skip_marked?(filepath)
cmd = Mixlib::ShellOut.new(
"#{@bin} ls-files -v #{filepath}",
[@bin, 'ls-files', '-v', filepath],
cwd: File.expand_path(@repo_path)
)
stdout = exec_cmd(cmd, 'Failed to check if file should be skipped.')
Expand All @@ -147,7 +147,7 @@ def skip_marked?(filepath)

def ref_exists?(ref)
cmd = Mixlib::ShellOut.new(
"#{@bin} cat-file -t #{ref}",
[@bin, 'cat-file', '-t', ref],
cwd: File.expand_path(@repo_path)
)
cmd.run_command
Expand Down