CocoaPods / cocoapods-downloader

A small library that provides downloaders for various source types (HTTP/SVN/Git/Mercurial)
MIT License
84 stars 72 forks source link

cocoapods checkout wrong branch if pod's branch name is separated by slashes #88

Closed tripleCC closed 4 years ago

tripleCC commented 5 years ago

Assume that pod A only has a branch named release/0.1.0.

...
pod 'A', git: 'xxx', branch: '0.1.0'
...

Install project with the Podfile above, and it will checkout release/0.1.0 branch.

def self.preprocess_options(options)
  return options unless options[:branch]

  command = ['ls-remote',
             options[:git],
             options[:branch]]
  output = Git.execute_command('git', command)  # will return release/0.1.0 branch
  match = /^([a-z0-9]*)\t.*/.match(output)

  return options if match.nil?

  options[:commit] = match[1]
  options.delete(:branch)

  options
end

I think /^([a-z0-9]*)\t.*/ is not strict for the case.

dnkoutso commented 5 years ago

Please make a PR and add tests?