diff --git a/lib/clone_git_file.rb b/lib/clone_git_file.rb index 8e13d54..7d37c90 100644 --- a/lib/clone_git_file.rb +++ b/lib/clone_git_file.rb @@ -40,9 +40,9 @@ def launch_editor # change into the directory so that relative file loads will work if File.directory?(file_path) - commands << "cd #{file_path}" + commands << %(cd "#{file_path}") else - commands << "cd #{File.dirname(file_path)}" + commands << %(cd "#{File.dirname(file_path)}") end commands << %(\n#{ENV["EDITOR"]} "#{file_path}") @@ -62,11 +62,11 @@ def print_clone_location def clone_repo commands = "" - commands << "git clone #{parsed_data.repo_url} #{local_repo_path}" + commands << %(git clone #{parsed_data.repo_url} "#{local_repo_path}") branch_name = parsed_data.branch_name if branch_name && branch_name != "" - commands << "\ncd #{local_repo_path}" + commands << %(\ncd "#{local_repo_path}") commands << "\ngit checkout #{parsed_data.branch_name}" end @@ -78,7 +78,7 @@ def clone_repo def update_repo commands = "" - commands << "cd #{local_repo_path}" + commands << %(cd "#{local_repo_path}") commands << "\ngit reset HEAD --hard" commands << "\ngit pull" commands << "\ngit checkout #{parsed_data.branch_name}" if parsed_data.branch_name diff --git a/lib/clone_git_file/version.rb b/lib/clone_git_file/version.rb index 9906400..6cafbdd 100644 --- a/lib/clone_git_file/version.rb +++ b/lib/clone_git_file/version.rb @@ -1,3 +1,3 @@ module CloneGitFile - VERSION = "0.1.6" + VERSION = "0.1.7" end diff --git a/spec/clone_git_file_spec.rb b/spec/clone_git_file_spec.rb index efd5688..4bb55ab 100644 --- a/spec/clone_git_file_spec.rb +++ b/spec/clone_git_file_spec.rb @@ -28,7 +28,7 @@ let(:cloner) { ::CloneGitFile::Cloner.new(url) } it "clones new repos" do - expected_clone_command = "git clone https://github.com/author/repo /target/author/repo" + expected_clone_command = %(git clone https://github.com/author/repo "/target/author/repo") expected_output = "Cloned to: /target/author/repo/some/file.rb" allow(Dir).to receive(:exists?).and_return(false) expect(cloner).to receive(:system).with(expected_clone_command) @@ -37,7 +37,7 @@ end it "updates repos which exist in target directory" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) expected_output = "Cloned to: /target/author/repo/some/file.rb" allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) @@ -55,8 +55,8 @@ let(:url) { "https://github.com/author/repo/some/file.rb" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo/some\nmyeditor "/target/author/repo/some/file.rb") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo/some"\nmyeditor "/target/author/repo/some/file.rb") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -68,8 +68,8 @@ let(:url) { "https://github.com/author/repo/some" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo/some\nmyeditor "/target/author/repo/some") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo/some"\nmyeditor "/target/author/repo/some") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -81,8 +81,8 @@ let(:url) { "https://github.com/author/repo" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo\nmyeditor "/target/author/repo") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo"\nmyeditor "/target/author/repo") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -94,8 +94,8 @@ let(:url) { "https://github.com/author/repo/" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo\nmyeditor "/target/author/repo") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo"\nmyeditor "/target/author/repo") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -113,8 +113,8 @@ let(:url) { "https://github.com/author/repo/some/file.rb" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo/some\nmyeditor "/target/author/repo/some/file.rb") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo/some"\nmyeditor "/target/author/repo/some/file.rb") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -126,8 +126,8 @@ let(:url) { "https://github.com/author/repo/some" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo/some\nmyeditor "/target/author/repo/some") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo/some"\nmyeditor "/target/author/repo/some") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -139,8 +139,8 @@ let(:url) { "https://github.com/author/repo" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo\nmyeditor "/target/author/repo") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo"\nmyeditor "/target/author/repo") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -152,8 +152,8 @@ let(:url) { "https://github.com/author/repo/" } it "outputs the commands to the terminal instead of executing them" do - expected_update_command = "cd /target/author/repo\ngit reset HEAD --hard\ngit pull" - expected_output = %(cd /target/author/repo\nmyeditor "/target/author/repo") + expected_update_command = %(cd "/target/author/repo"\ngit reset HEAD --hard\ngit pull) + expected_output = %(cd "/target/author/repo"\nmyeditor "/target/author/repo") allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) expect(cloner).to receive(:puts).with(expected_output) @@ -168,7 +168,7 @@ let(:cloner) { ::CloneGitFile::Cloner.new(url, silent: true) } it "redirects output" do - expected_update_command = "cd /target/author/repo &> /dev/null\ngit reset HEAD --hard &> /dev/null\ngit pull &> /dev/null" + expected_update_command = %(cd "/target/author/repo" &> /dev/null\ngit reset HEAD --hard &> /dev/null\ngit pull &> /dev/null) expected_output = "Cloned to: /target/author/repo/some/file.rb" allow(Dir).to receive(:exists?).and_return(true) expect(cloner).to receive(:system).with(expected_update_command) @@ -183,8 +183,8 @@ let(:cloner) { ::CloneGitFile::Cloner.new(url, open_in_editor: true) } it "clones new repos" do - expected_clone_command = "git clone https://github.com/author/repo /target/author/repo" - expected_launch_command = %(cd /target/author/repo/some\nmyeditor "/target/author/repo/some/file.rb") + expected_clone_command = %(git clone https://github.com/author/repo "/target/author/repo") + expected_launch_command = %(cd "/target/author/repo/some"\nmyeditor "/target/author/repo/some/file.rb") allow(Dir).to receive(:exists?).and_return(false) expect(cloner).to receive(:system).with(expected_clone_command) expect(cloner).to receive(:system).with(expected_launch_command) @@ -197,8 +197,8 @@ let(:cloner) { ::CloneGitFile::Cloner.new(url, open_in_editor: true) } it "clones new repos" do - expected_clone_command = "git clone https://github.com/author/repo /target/author/repo" - expected_launch_command = %(cd /target/author/repo\nmyeditor "/target/author/repo") + expected_clone_command = %(git clone https://github.com/author/repo "/target/author/repo") + expected_launch_command = %(cd "/target/author/repo"\nmyeditor "/target/author/repo") allow(Dir).to receive(:exists?).and_return(false) expect(cloner).to receive(:system).with(expected_clone_command) expect(cloner).to receive(:system).with(expected_launch_command) @@ -211,8 +211,8 @@ let(:cloner) { ::CloneGitFile::Cloner.new(url, open_in_editor: true) } it "clones new repos" do - expected_clone_command = "git clone https://github.com/author/repo /target/author/repo" - expected_launch_command = %(cd /target/author/repo/some\nmyeditor "/target/author/repo/some") + expected_clone_command = %(git clone https://github.com/author/repo "/target/author/repo") + expected_launch_command = %(cd "/target/author/repo/some"\nmyeditor "/target/author/repo/some") allow(Dir).to receive(:exists?).and_return(false) expect(cloner).to receive(:system).with(expected_clone_command) expect(cloner).to receive(:system).with(expected_launch_command) @@ -225,8 +225,8 @@ let(:cloner) { ::CloneGitFile::Cloner.new(url, open_in_editor: true) } it "clones new repos" do - expected_clone_command = "git clone https://github.com/author/repo /target/author/repo" - expected_launch_command = %(cd /target/author/repo\nmyeditor "/target/author/repo") + expected_clone_command = %(git clone https://github.com/author/repo "/target/author/repo") + expected_launch_command = %(cd "/target/author/repo"\nmyeditor "/target/author/repo") allow(Dir).to receive(:exists?).and_return(false) expect(cloner).to receive(:system).with(expected_clone_command) expect(cloner).to receive(:system).with(expected_launch_command)