Skip to content

Commit

Permalink
Merge pull request #61 from CocoaPods/seg-fix-commit-with-submodules
Browse files Browse the repository at this point in the history
[Git] Fix checking out a commit with submodules
  • Loading branch information
endocrimes committed Aug 22, 2016
2 parents 1932ea3 + c09fccd commit be0cebb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 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.
* Ensure submodules are updated after checking out a specific git commit.
[Samuel Giddins](https://github.com/segiddins)
[CocoaPods#5778](https://github.com/CocoaPods/CocoaPods/issues/5778)


## 1.1.0 (2016-07-11)
Expand Down
15 changes: 9 additions & 6 deletions lib/cocoapods-downloader/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ def clone(force_head = false, shallow_clone = true)
ui_sub_action('Git download') do
begin
git! clone_arguments(force_head, shallow_clone)

if options[:submodules]
Dir.chdir(target_path) do
git! %w(submodule update --init --recursive)
end
end
update_submodules
rescue DownloaderError => e
if e.message =~ /^fatal:.*does not support --depth$/im
clone(force_head, false)
Expand All @@ -95,6 +90,13 @@ def clone(force_head = false, shallow_clone = true)
end
end

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

# The arguments to pass to `git` to clone the repo.
#
# @param [Bool] force_head
Expand Down Expand Up @@ -128,6 +130,7 @@ def clone_arguments(force_head, shallow_clone)
def checkout_commit
Dir.chdir(target_path) do
git! 'checkout', '--quiet', options[:commit]
update_submodules
end
end
end
Expand Down

0 comments on commit be0cebb

Please sign in to comment.