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

Fix git add command to handle paths with spaces #10866

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion common/lib/dependabot/workspace/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def stash(memo = nil)

sig { params(memo: T.nilable(String)).returns([String, String]) }
def commit(memo = nil)
run_shell_command("git add #{path}")
run_shell_command(%(git add "#{path}"), allow_unsafe_shell_command: true)
diff = run_shell_command("git diff --cached .")

msg = memo || "workspace change"
Expand Down
2 changes: 1 addition & 1 deletion common/spec/dependabot/workspace/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RSpec.describe Dependabot::Workspace::Git do
subject(:workspace) { described_class.new(repo_contents_path) }

let(:repo_contents_path) { build_tmp_repo("simple", tmp_dir_path: Dir.tmpdir) }
let(:repo_contents_path) { build_tmp_repo("simple", tmp_dir_path: File.join(Dir.tmpdir, "with space")) }

around do |example|
Dir.chdir(repo_contents_path) { example.run }
Expand Down
Loading