git-version-bump 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +41 -12
- data/bin/git-version-bump +39 -0
- data/git-version-bump.gemspec +2 -1
- data/lib/git-version-bump.rb +5 -1
- data/lib/git-version-bump/rake-tasks.rb +9 -0
- metadata +7 -5
data/README.md
CHANGED
@@ -1,14 +1,44 @@
|
|
1
1
|
Maintain your program versions entirely within git. No local files
|
2
|
-
required!
|
2
|
+
required! All versioning information is stored using git tags.
|
3
3
|
|
4
|
-
This gem contains a set of Rake tasks
|
5
|
-
|
6
|
-
your
|
4
|
+
This gem contains a command-line tool and set of Rake tasks to increment
|
5
|
+
and display your version numbers via git tags, and some associated Ruby code to use
|
6
|
+
inside a gemspec or your program to retrieve the current version number, for
|
7
|
+
use in builds and at runtime.
|
7
8
|
|
8
9
|
|
9
10
|
# Usage
|
10
11
|
|
11
|
-
|
12
|
+
Most of your day-to-day usage of `git-version-bump` will be via the command
|
13
|
+
line. When you bump a version, a new tag will be created representing the newly
|
14
|
+
incremented version number at the current commit. If no tags currently
|
15
|
+
exist, the previous version will be taken to be `0.0.0` and then incremented
|
16
|
+
accordingly.
|
17
|
+
|
18
|
+
|
19
|
+
## On the command line
|
20
|
+
|
21
|
+
Pretty damned trivial:
|
22
|
+
|
23
|
+
git version-bump <major|minor|patch|show>
|
24
|
+
|
25
|
+
You can also shorten the specifier to any unique substring:
|
26
|
+
|
27
|
+
git version-bump ma
|
28
|
+
git version-bump mi
|
29
|
+
git version-bump p
|
30
|
+
git version-bump s
|
31
|
+
|
32
|
+
I recommend adding an alias to your `~/.gitconfig` file, for less typing:
|
33
|
+
|
34
|
+
[alias]
|
35
|
+
vb = version-bump
|
36
|
+
|
37
|
+
|
38
|
+
## In your `Rakefile`
|
39
|
+
|
40
|
+
If you'd like to have access to the version-bumping goodness via `rake`, add
|
41
|
+
the following line to your `Rakefile`:
|
12
42
|
|
13
43
|
require 'git-version-bump/rake-tasks'
|
14
44
|
|
@@ -17,15 +47,14 @@ You will now have the following rake tasks available:
|
|
17
47
|
rake version:bump:major # bump major version (x.y.z -> x+1.0.0)
|
18
48
|
rake version:bump:minor # bump minor version (x.y.z -> x.y+1.0)
|
19
49
|
rake version:bump:patch # bump patch version (x.y.z -> x.y.z+1)
|
50
|
+
rake version:bump:show # Print current version number
|
20
51
|
|
21
52
|
(Since `version:bump:major` is a lot of typing, there are also shortcuts:
|
22
53
|
`v:b:major`, `v:b:maj`, `v:b:minor`, `v:b:min`, `v:b:patch`, `v:b:pat`, and
|
23
54
|
`v:b:p`)
|
24
55
|
|
25
|
-
|
26
|
-
|
27
|
-
exist, the previous version will be taken to be `0.0.0` and then incremented
|
28
|
-
accordingly.
|
56
|
+
|
57
|
+
## In your Ruby code
|
29
58
|
|
30
59
|
To get access to this version information in your code (such as in your
|
31
60
|
`gemspec`, or the definition of a `::VERSION` constant), you can `require
|
@@ -50,7 +79,7 @@ information available, the version will be assumed to be `0.0.0.1.ENOTAG`
|
|
50
79
|
with a date of `1970-01-01`.
|
51
80
|
|
52
81
|
|
53
|
-
|
82
|
+
### In your gemspec
|
54
83
|
|
55
84
|
Typically, you want to encode your version and commit date into your
|
56
85
|
gemspec, like this:
|
@@ -69,10 +98,10 @@ system was built from pristine sources, or with that experimental patch you
|
|
69
98
|
were trying out...
|
70
99
|
|
71
100
|
|
72
|
-
|
101
|
+
### In your gem
|
73
102
|
|
74
103
|
If, like me, you're one of those people who likes to be able to easily see
|
75
|
-
what version of a library
|
104
|
+
what version of a library you're running, then you probably like to define a
|
76
105
|
`VERSION` constant somewhere in your gem's namespace. That, too, is simple
|
77
106
|
to do:
|
78
107
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'git-version-bump'
|
4
|
+
|
5
|
+
if ARGV[0].nil? or
|
6
|
+
ARGV[0].empty? or
|
7
|
+
ARGV[0] == '-h' or
|
8
|
+
ARGV[0] == '--help'
|
9
|
+
$stderr.puts <<-EOF.gsub(/^\t\t/, '')
|
10
|
+
Usage: git version-bump <major|minor|patch>
|
11
|
+
|
12
|
+
'major': x.y.z -> x+1.0.0
|
13
|
+
'minor': x.y.z -> x.y+1.0
|
14
|
+
'patch': x.y.z -> x.y.z+1
|
15
|
+
EOF
|
16
|
+
end
|
17
|
+
|
18
|
+
if ARGV[0].nil? or ARGV[0].empty?
|
19
|
+
exit 1
|
20
|
+
elsif ARGV[0] == '-h' or ARGV[0] == '--help'
|
21
|
+
exit 0
|
22
|
+
end
|
23
|
+
|
24
|
+
case ARGV[0].downcase
|
25
|
+
when /^maj?o?r?$/
|
26
|
+
GVB.tag_version "#{GVB.major_version + 1}.0.0"
|
27
|
+
when /^min?o?r?$/
|
28
|
+
GVB.tag_version "#{GVB.major_version}.#{GVB.minor_version+1}.0"
|
29
|
+
when /^pa?t?c?h?$/
|
30
|
+
GVB.tag_version "#{GVB.major_version}.#{GVB.minor_version}.#{GVB.patch_version+1}"
|
31
|
+
when /^sh?o?w?$/
|
32
|
+
puts GVB.version
|
33
|
+
exit 0
|
34
|
+
else
|
35
|
+
$stderr.puts "Unknown argument: #{ARGV[0]}. Try --help."
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
|
39
|
+
puts "Version is now #{GVB.version}."
|
data/git-version-bump.gemspec
CHANGED
@@ -14,7 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.extra_rdoc_files = ["README.md"]
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
|
-
|
17
|
+
s.executables = ["git-version-bump"]
|
18
|
+
|
18
19
|
s.add_development_dependency 'rake'
|
19
20
|
s.add_development_dependency 'bundler'
|
20
21
|
s.add_development_dependency 'rdoc'
|
data/lib/git-version-bump.rb
CHANGED
@@ -34,6 +34,10 @@ module GitVersionBump
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.version(gem = nil)
|
37
|
+
@version_cache ||= {}
|
38
|
+
|
39
|
+
return @version_cache[gem] if @version_cache[gem]
|
40
|
+
|
37
41
|
git_ver = `git describe --dirty='.1.dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}' --match='v[0-9]*.[0-9]*.*[0-9]' 2>/dev/null`.
|
38
42
|
strip.
|
39
43
|
gsub(/^v/, '').
|
@@ -66,7 +70,7 @@ module GitVersionBump
|
|
66
70
|
# weren't called from within a loaded gem, and so we've got *no*
|
67
71
|
# idea what's going on. Time to bail!
|
68
72
|
raise RuntimeError,
|
69
|
-
"GVB.version(#{gem.inspect})
|
73
|
+
"GVB.version(#{gem.inspect}) failed. Is git installed?"
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
@@ -22,6 +22,11 @@ namespace :version do
|
|
22
22
|
|
23
23
|
puts "Version is now #{GVB.version}"
|
24
24
|
end
|
25
|
+
|
26
|
+
desc "Print current version"
|
27
|
+
task :show do
|
28
|
+
puts GVB.version
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
@@ -36,5 +41,9 @@ namespace :v do
|
|
36
41
|
task :patch => "version:bump:patch"
|
37
42
|
task :pat => "version:bump:patch"
|
38
43
|
task :p => "version:bump:patch"
|
44
|
+
|
45
|
+
task :show => "version:bump:show"
|
46
|
+
task :sh => "version:bump:show"
|
47
|
+
task :s => "version:bump:show"
|
39
48
|
end
|
40
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-version-bump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -61,7 +61,8 @@ dependencies:
|
|
61
61
|
version: '0'
|
62
62
|
description:
|
63
63
|
email:
|
64
|
-
executables:
|
64
|
+
executables:
|
65
|
+
- git-version-bump
|
65
66
|
extensions: []
|
66
67
|
extra_rdoc_files:
|
67
68
|
- README.md
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- Gemfile
|
71
72
|
- README.md
|
72
73
|
- Rakefile
|
74
|
+
- bin/git-version-bump
|
73
75
|
- git-version-bump.gemspec
|
74
76
|
- lib/git-version-bump.rb
|
75
77
|
- lib/git-version-bump/rake-tasks.rb
|
@@ -87,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
89
|
version: '0'
|
88
90
|
segments:
|
89
91
|
- 0
|
90
|
-
hash: -
|
92
|
+
hash: -3956615801826870030
|
91
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
94
|
none: false
|
93
95
|
requirements:
|
@@ -96,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
98
|
version: '0'
|
97
99
|
segments:
|
98
100
|
- 0
|
99
|
-
hash: -
|
101
|
+
hash: -3956615801826870030
|
100
102
|
requirements: []
|
101
103
|
rubyforge_project:
|
102
104
|
rubygems_version: 1.8.23
|