简体   繁体   中英

How does Bundler know how to use a specific gem version?

I noticed that there exists a habit of tagging version releases of gems. This way, I could understand that bundler would try to checkout a specific tag, and try to build that specific gemspec.

But, however, I also found out the gem-release gem from Sven Fuchs. I would have expected that the bump commands are creating tags for each version of a gem. However, all that I see happening is a modification of the version.rb file ( no tags are being created ). Could you shed some light on what exactly happens when I say:

gem "some_gem","0.0.1"

and what happens when I say:

gem "some_gem","0.0.2"

How is bundler installing them? What if instead of the above commands ( assuming that I cloned the gem's repo ), I write:

gem "some_gem","0.0.3",:path => "~/some/path"

How would the correct gem version be used now?

Bundler by default gets its gems from http://rubygems.org/ , not from Github. Rubygems has the actual released versions when an author actually releases them.

If you tell bundler to install from a git address, eg. with :git => "git://github.com/svenfuchs/gem-release.git" , or github with :github => "svenfuchs/gem-release" , it will actually get it from the repository.

If no other options are specified, bundler will get the latest commit (the HEAD) on the default branch (master). In this case, bundler considers the version to be the commit hash. Similarly if you specify the :branch option, it just uses a different branch.

If you specify a version, it finds the tag which matches the version you request. You should know that tags are not part of commits. A tag in a git repository is a pointer to a commit. You can find all the tags by browsing for them at https://github.com/svenfuchs/gem-release/tags .

You will notice that the tag v0.4.1 refers to the commit hash 34f563bd294c2... , which links to the commit . However, because the tag is not part of the commit, you will not see the tagging action in the commit itself. You will only see that the tag refers to that commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM