Skip to content

Commit

Permalink
Make gem self versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
the-michael-toy committed Mar 20, 2017
1 parent 5d42d74 commit 4e1c51c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions nullgem.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
Gem::Specification.new do |gem|
gem.name = "nullgem"
gem.version = '0.0.0'
gem.date = '2001-01-01'
gem.version = begin
head_sha = %x{git rev-parse HEAD}.strip
tag_version = %x{git name-rev --tags --name-only #{head_sha}}.strip
untracked_files = (%x{git ls-files --others --exclude-standard}.strip != '')
_diff_status_only = %x{git diff --quiet --exit-code HEAD}
head_diff = ($?.exitstatus != 0)

version = (tag_version =~ /^\d+\.\d+\.\d+$/) ? tag_version : "0.0.0.#{head_sha[0..7]}"
dev_tag = (untracked_files || head_diff) ? '-dev' : ''

version + dev_tag
end
gem.date = '2012-03-04'
gem.authors = ["Michael Toy"]
gem.email = ["[email protected]"]
gem.description = %q{A gem which does nothing, for testing}
Expand Down

0 comments on commit 4e1c51c

Please sign in to comment.