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

Force encode branch name to properly clone it. #116

Merged
merged 1 commit into from
Aug 9, 2021
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
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