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
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

##### Bug Fixes

* None.
* Use `git -C` rather than `chdir`.
[Danielle Tomlinson](https://github.com/dantoml)
[#62](https://github.com/CocoaPods/cocoapods-downloader/pull/62)


## 1.1.1 (2016-08-30)
Expand Down
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] = target_git('rev-parse', 'HEAD').chomp
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