Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Print git commit when running Bundler from a git checkout #5049

Closed
indirect opened this issue Oct 4, 2016 · 1 comment
Closed

Print git commit when running Bundler from a git checkout #5049

indirect opened this issue Oct 4, 2016 · 1 comment

Comments

@indirect
Copy link
Member

indirect commented Oct 4, 2016

When running bundler directly from a git checkout (for example via the dbundle alias suggested by DEVELOPMENT.md), it would be SUPER helpful to print the git commit out when running dbundle --version, and also when running bundle env.

@segiddins
Copy link
Member

segiddins commented Oct 4, 2016

diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 3f9a1211f..909d80964 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -7,7 +7,17 @@ module Bundler
   # We're doing this because we might write tests that deal
   # with other versions of bundler and we are unsure how to
   # handle this better.
-  VERSION = "1.15.1" unless defined?(::Bundler::VERSION)
+  unless defined?(::Bundler::VERSION)
+    require "bundler/constants"
+    git = File.expand_path("../../../.git", __FILE__)
+    if File.directory?(git)
+      Dir.chdir(git) do
+        git_describe = `git describe --always 2>#{NULL}`.strip.sub(/^v/, "")
+        VERSION = git_describe unless git_describe.empty?
+      end
+    end
+    VERSION = "1.15.1" unless defined?(::Bundler::VERSION)
+  end
 
   def self.overwrite_loaded_gem_version
     begin

@segiddins segiddins self-assigned this Jun 2, 2017
bundlerbot added a commit that referenced this issue Jun 16, 2017
Print build metadata when running `bundle version`

Closes #5049.

Will get all the build metadata into `bundle env` once #5703 lands, since I don't want conflicts and want to use that code for generating the "tables"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants