Skip to content

Commit

Permalink
Merge pull request #62 from CocoaPods/dani_git_c
Browse files Browse the repository at this point in the history
[Git] Remove calls to Dir.chdir
  • Loading branch information
segiddins authored Oct 16, 2016
2 parents 978dfcd + 31719bb commit 9ceb3f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
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

0 comments on commit 9ceb3f0

Please sign in to comment.