rubygems / bundler

Manage your Ruby application's gem dependencies
https://bundler.io
MIT License
4.88k stars 2k forks source link

Use full revision SHAs in Gemfile.lock [patch] #580

Closed pwnall closed 14 years ago

pwnall commented 14 years ago

I have the following in my Gemfile gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => '3-0-stable'

I'm getting the following error when I bundle install: error: short SHA1 6f478b0 is ambiguous. error: short SHA1 6f478b0 is ambiguous. fatal: ambiguous argument '6f478b0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

Looking at http://github.com/rails/rails/commits/3-0-stable shows me that the top commit matches. I think the full git SHA should be used in Gemfile.lock, to avoid such unpleasant surprises at deploy time.

Thank you!

pwnall commented 14 years ago

I worked on a patch http://github.com/pwnall/bundler/commit/33c9f938fd7d554609e106e2cb6831e8d3502566

Note: the birthday paradox suggests minimum ref prefix lengths. For a length l, there will be a 50% chance of a conflict given roughly 2^l commits (which is sqrt(4^l ). I'm not particularly attached to the ref prefix lengths I used for paths and display, but I think it is important to have the full ref in the lockfile.

pwnall commented 14 years ago

Actually "on the order of" isn't too good. The probability table on Wikipedia is better http://en.wikipedia.org/wiki/Birthday_problem#Probability_table -- our hash size is 4*L where L is the ref prefix length.

pwnall commented 14 years ago

I'd be happy to address any feedback on the patch, if that helps.

wycats commented 14 years ago

Pulled :)