Skip to content

Commit

Permalink
Warn about making non-release gems
Browse files Browse the repository at this point in the history
Abbreviating the full version number of an intermediate build (eg.
"1.1b2-10-g61a374a") to the last tag (eg. "1.1b2") is evil, because it
means we end up labelling distinct versions of the software with the
same version number.

Unfortuantely, however, it is a necessary evil because RubyGems will
choke if passed an intermediate version number:

  Invalid gemspec in [command-t.gemspec]: Malformed version number string
  1.1b2-10-g61a374a
  ERROR:  While executing gem ... (NoMethodError)
      undefined method `mark_version' for nil:NilClass
      rake aborted!

So, we resort to using the abbreviated, misleading version number in
this case. We can at least mitigate this evilness by displaying a
warning if the user ever tries to build a gem for an intermediate
release, by adding a dependency on the ":check_tag" task.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information
wincent committed Apr 30, 2011
1 parent 61a374a commit a2545f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Rakefile
Expand Up @@ -12,6 +12,12 @@ def version
`git describe`.chomp
end

def rubygems_version
# RubyGems will barf if we try to pass an intermediate version number
# like "1.1b2-10-g61a374a", so no choice but to abbreviate it
`git describe --abbrev=0`.chomp
end

def yellow
"\033[33m"
end
Expand Down Expand Up @@ -196,12 +202,11 @@ task :archive => :vimball do
end

desc 'Create the ruby gem package'
task :gem do
task :gem => :check_tag do
sh "gem build command-t.gemspec"
end

desc 'Install the command-t ruby gem'
task :install => :gem do
v = `git describe --abbrev=0`.chomp
sh "gem install command-t-#{v}.gem"
task :install => :gem do
sh "gem install command-t-#{rubygems_version}.gem"
end
3 changes: 3 additions & 0 deletions command-t.gemspec
@@ -1,5 +1,8 @@
Gem::Specification.new do |s|
s.name = "command-t"

# see note in the Rakefile about how intermediate version numbers
# can break RubyGems
v = `git describe --abbrev=0`.chomp
s.version = v

Expand Down

0 comments on commit a2545f5

Please sign in to comment.