Skip to content

Commit

Permalink
Force encode branch name to properly clone it.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Aug 3, 2021
1 parent 2a9db9d commit 0de094b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

##### Bug Fixes

* None.
* Force encode branch name to properly clone it.
[xdkhan](https://github.com/xdkhan)
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#116](https://github.com/CocoaPods/cocoapods-downloader/pull/116)


## 1.4.0 (2020-07-17)
Expand Down
3 changes: 2 additions & 1 deletion lib/cocoapods-downloader/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def self.preprocess_options(options)
#
def self.commit_from_ls_remote(output, branch_name)
return nil if branch_name.nil?
match = %r{([a-z0-9]*)\trefs\/(heads|tags)\/#{Regexp.quote(branch_name)}}.match(output)
encoded_branch_name = branch_name.force_encoding(Encoding::ASCII_8BIT)
match = %r{([a-z0-9]*)\trefs\/(heads|tags)\/#{Regexp.quote(encoded_branch_name)}}.match(output)
match[1] unless match.nil?
end

Expand Down
Binary file modified spec/fixtures/git-repo.tar.gz
Binary file not shown.
7 changes: 7 additions & 0 deletions spec/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ def fixture_url(name)
tmp_folder('README').read.strip.should == 'topic_branch'
end

it 'checks out a specific branch with forced encoding' do
options = { :git => fixture('git-repo'), :branch => '中文分支' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.download
tmp_folder('README').read.strip.should == '中文分支'
end

it 'checks out a specific tag' do
options = { :git => fixture('git-repo'), :tag => 'v1.0' }
downloader = Downloader.for_target(tmp_folder, options)
Expand Down

0 comments on commit 0de094b

Please sign in to comment.