Search code examples
ruby-on-railsrubygemsruby-on-rails-5bundlergemfile

Does bundler search all branches of a repo for the commit when using `ref` option for Gemfile source?


Does bundler search within all branches of a repo for the commit when using ref option for Gemfile source?

gem 'rails', github: 'rails', ref: 'a9752dcfd15bcddfe7b6f7126f3a6e0ba5927c56'

As an example, if the commit hash a9752dcfd15bcddfe7b6f7126f3a6e0ba5927c56 does not exist on the main or master branch, will bundler still find the commit if it exists on another branch such as feature1 (and is not the latest commit so the branch: option will not suffice)?


Solution

  • if the commit hash a9752dcfd15bcddfe7b6f7126f3a6e0ba5927c56 does not exist on the main or master branch, will bundler still find the commit if it exists on another branch such as feature1 (and is not the latest commit so the branch: option will not suffice)?

    Yes.

    Bundler will be able to fetch the specified ref even if doesn't merged to master branch. It is easy to do for Bundler because of nature of Git/GitHub: you could pick any commit by reference independent of the branches that commit merged to.

    According to the source code of Bundler:

    • ref option has an advantage over branch option
    • branch option has an advantage over tag option

    Both branch and tag are symbolic names for refs and used just for human convenient.