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

[Git] Remove calls to Dir.chdir #62

Merged
merged 4 commits into from
Oct 16, 2016
Merged
Changes from 1 commit
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
26 changes: 12 additions & 14 deletions lib/cocoapods-downloader/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ def options_specific?
end

def checkout_options
Dir.chdir(target_path) do
options = {}
options[:git] = url
options[:commit] = `git rev-parse HEAD`.chomp
options[:submodules] = true if self.options[:submodules]
options
end
options = {}
options[:git] = url
options[:commit] = `git -C #{target_path} rev-parse HEAD`.chomp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add quotes around #{target_path}

options[:submodules] = true if self.options[:submodules]
options
end

def self.preprocess_options(options)
Expand Down Expand Up @@ -92,9 +90,7 @@ def clone(force_head = false, shallow_clone = true)

def update_submodules
return unless options[:submodules]
Dir.chdir(target_path) do
git! %w(submodule update --init --recursive)
end
target_git %w(submodule update --init --recursive)
end

# The arguments to pass to `git` to clone the repo.
Expand Down Expand Up @@ -128,10 +124,12 @@ def clone_arguments(force_head, shallow_clone)
# Checks out a specific commit of the cloned repo.
#
def checkout_commit
Dir.chdir(target_path) do
git! 'checkout', '--quiet', options[:commit]
update_submodules
end
target_git 'checkout', '--quiet', options[:commit]
update_submodules
end

def target_git(*args)
git!(['-C', target_path] + args)
end
end
end
Expand Down