including version from git in built gem without updating Gemfile.lock

27 views
Skip to first unread message

Darragh Bailey

unread,
Apr 9, 2015, 12:00:11 PM4/9/15
to rubyge...@googlegroups.com

Hi,


I'm working on a vagrant plugin which is essentially a gem, but it also has a Gemfile.lock so I guess it's closer to an app than a component. I'd like to modify it so that when I build gems from the project when it's being hacked on, that anything that is not from a released tag automatically appends the number of commits since the release and the sha1 to the resulting version used for the gem.

This makes it relatively easy to distinguish that I've got a modified version of the plugin installed. Combined with the bump gem, it makes should make it straight forward to manage all the version information directly from git tags in the future.


I've gotten the gem building part with the modifiied working reasonably well, but what's tripping me up is that if I use 'bundle exec rake build', the Gemfile.lock for the project gets updated with the new version for the current project, which is fine except I don't think it makes sense to commit a change such as the following for each commit after switching to this approach:

--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -19,7 +19,7 @@ GIT
 PATH
   remote: .
   specs:
-    vagrant-chef-zero (0.7.1)
+    vagrant-chef-zero (0.7.1.7.pre.g9c90dea)
       chef (~> 11.0)
       chef-zero (~> 2.0)
       ridley (>= 1.0.0)
----------------------

The last '7' in 0.7.1.7 is the number of commits since 0.7.1 was released and tagged.


So I've started looking at the Rakefile and seeing if I should just change the behaviour of the build task so that it calls a different version function when not building a release.

Seems that part of my problem might be some of the assumptions being made about the version since the Rakefile is using:
require 'bundler/setup'
require 'bundler/gem_tasks'

Which appears to grab the version in a particularly way that is difficult to control without subclassing and overriding the various methods.


Going down this route seems to result in various hackery and I'm not sure that I understand enough to have bundle, rake and gem calls all work as expected.

I'm hoping that someone might be familiar with a pattern around rake tasks and gem versioning that allows use of git tags and auto generating post release versions for builds after releases without breaking how these tools work.

--
Darragh
Reply all
Reply to author
Forward
0 new messages