git-version-bump 0.15.1 → 0.16.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.
- checksums.yaml +5 -5
- data/bin/git-version-bump +15 -7
- data/git-version-bump.gemspec +3 -1
- data/lib/git-version-bump.rb +32 -21
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 94d95a18eae098b144f0f9afff676405cb1a05cf35b6786410e160269d7b34ec
|
4
|
+
data.tar.gz: db3e976ffa2d7e5493c957d340aafaffdd570d45bc3db83e2f0d6f70742e58c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2a692ace08cda02976a2647dec09b978a82829e51e7bdec4a93c7954d3e4728e24bcac211fa128861fec979f5f41290e88ca40f6e04feb371f362854abf9e3
|
7
|
+
data.tar.gz: 737dd2b41d89ca7d33722948e69a9de74f10e260d4776aba82cfee9f6b4a15df28042b86d839ceb53012ac7a1247278b8e46b259e10ced7cae904cadb512510d
|
data/bin/git-version-bump
CHANGED
@@ -4,10 +4,11 @@ require 'git-version-bump'
|
|
4
4
|
|
5
5
|
if ARGV[0].nil? or
|
6
6
|
ARGV[0].empty? or
|
7
|
+
(ARGV.length == 1 && (ARGV[0] == "-d" || ARGV[0] == "--dry-run")) or
|
7
8
|
ARGV[0] == '-h' or
|
8
9
|
ARGV[0] == '--help'
|
9
10
|
$stderr.puts <<-EOF.gsub(/^\t\t/, '')
|
10
|
-
Usage: git version-bump [-n|--notes] <major|minor|patch|show>
|
11
|
+
Usage: git version-bump [-n|--notes] [-d|--dry-run] <major|minor|patch|show>
|
11
12
|
|
12
13
|
'major': x.y.z -> x+1.0.0
|
13
14
|
'minor': x.y.z -> x.y+1.0
|
@@ -15,11 +16,13 @@ if ARGV[0].nil? or
|
|
15
16
|
|
16
17
|
'show': Display the current GVB version
|
17
18
|
|
18
|
-
--
|
19
|
+
-d, --dry-run: Calculate and return the bump value, but don't update git workspace or remote
|
20
|
+
-n, --notes: Prompt for "release notes" to add to the release tag
|
19
21
|
EOF
|
20
22
|
end
|
21
23
|
|
22
24
|
release_notes = ARGV.delete('-n') || ARGV.delete('--notes')
|
25
|
+
dry_run = ARGV.delete('-d') || ARGV.delete('--dry-run')
|
23
26
|
|
24
27
|
if ARGV[0].nil? or ARGV[0].empty?
|
25
28
|
exit 1
|
@@ -27,13 +30,13 @@ elsif ARGV[0] == '-h' or ARGV[0] == '--help'
|
|
27
30
|
exit 0
|
28
31
|
end
|
29
32
|
|
30
|
-
case ARGV[0].downcase
|
33
|
+
result = case ARGV[0].downcase
|
31
34
|
when /^maj?o?r?$/
|
32
|
-
|
35
|
+
"#{GVB.major_version(true) + 1}.0.0"
|
33
36
|
when /^min?o?r?$/
|
34
|
-
|
37
|
+
"#{GVB.major_version(true)}.#{GVB.minor_version(true)+1}.0"
|
35
38
|
when /^pa?t?c?h?$/
|
36
|
-
|
39
|
+
"#{GVB.major_version(true)}.#{GVB.minor_version(true)}.#{GVB.patch_version(true)+1}"
|
37
40
|
when /^sh?o?w?$/
|
38
41
|
puts GVB.version(true)
|
39
42
|
exit 0
|
@@ -42,4 +45,9 @@ case ARGV[0].downcase
|
|
42
45
|
exit 1
|
43
46
|
end
|
44
47
|
|
45
|
-
|
48
|
+
if dry_run
|
49
|
+
puts result
|
50
|
+
else
|
51
|
+
GVB.tag_version result, release_notes
|
52
|
+
puts "Version is now #{GVB.version(true)}."
|
53
|
+
end
|
data/git-version-bump.gemspec
CHANGED
data/lib/git-version-bump.rb
CHANGED
@@ -5,6 +5,8 @@ require 'pathname'
|
|
5
5
|
module GitVersionBump
|
6
6
|
class VersionUnobtainable < StandardError; end
|
7
7
|
|
8
|
+
DEVNULL = Gem.win_platform? ? "NUL" : "/dev/null"
|
9
|
+
|
8
10
|
def self.version(use_local_git=false)
|
9
11
|
if use_local_git
|
10
12
|
unless git_available?
|
@@ -12,13 +14,12 @@ module GitVersionBump
|
|
12
14
|
"GVB.version(use_local_git=true) called, but git isn't installed"
|
13
15
|
end
|
14
16
|
|
15
|
-
sq_git_dir =
|
17
|
+
sq_git_dir = shell_quoted_string(Dir.pwd)
|
16
18
|
else
|
17
|
-
|
18
|
-
sq_git_dir = "'" + (File.dirname(caller_file) rescue nil || Dir.pwd).gsub("'", "'\\''") + "'"
|
19
|
+
sq_git_dir = shell_quoted_string((File.dirname(caller_file) rescue nil || Dir.pwd))
|
19
20
|
end
|
20
21
|
|
21
|
-
git_ver = `git -C #{sq_git_dir} describe --dirty='.1.dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}' --match='v[0-9]*.[0-9]*.*[0-9]' 2
|
22
|
+
git_ver = `git -C #{sq_git_dir} describe --dirty='.1.dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}' --match='v[0-9]*.[0-9]*.*[0-9]' 2> #{DEVNULL}`.
|
22
23
|
strip.
|
23
24
|
gsub(/^v/, '').
|
24
25
|
gsub('-', '.')
|
@@ -33,8 +34,8 @@ module GitVersionBump
|
|
33
34
|
# Are we in a git repo with no tags? If so, dump out our
|
34
35
|
# super-special version and be done with it, otherwise try to use the
|
35
36
|
# gem version.
|
36
|
-
system("git -C #{sq_git_dir} status
|
37
|
-
|
37
|
+
system("git -C #{sq_git_dir} status > #{DEVNULL} 2>&1")
|
38
|
+
$? == 0 ? "0.0.0.1.ENOTAG" : gem_version(use_local_git)
|
38
39
|
end
|
39
40
|
|
40
41
|
def self.major_version(use_local_git=false)
|
@@ -84,14 +85,13 @@ module GitVersionBump
|
|
84
85
|
"GVB.date(use_local_git=true), but git is not installed"
|
85
86
|
end
|
86
87
|
|
87
|
-
sq_git_dir =
|
88
|
+
sq_git_dir = shell_quoted_string(Dir.pwd)
|
88
89
|
else
|
89
|
-
|
90
|
-
sq_git_dir = "'" + (File.dirname(caller_file) rescue nil || Dir.pwd).gsub("'", "'\\''") + "'"
|
90
|
+
sq_git_dir = shell_quoted_string((File.dirname(caller_file) rescue nil || Dir.pwd))
|
91
91
|
end
|
92
92
|
|
93
93
|
# Are we in a git tree?
|
94
|
-
system("git -C #{sq_git_dir} status
|
94
|
+
system("git -C #{sq_git_dir} status > #{DEVNULL} 2>&1")
|
95
95
|
if $? == 0
|
96
96
|
# Yes, we're in git.
|
97
97
|
|
@@ -99,7 +99,7 @@ module GitVersionBump
|
|
99
99
|
return Time.now.strftime("%F")
|
100
100
|
else
|
101
101
|
# Clean tree. Date of last commit is needed.
|
102
|
-
return `git -C #{sq_git_dir} show --format=format:%cd --date=short
|
102
|
+
return `git -C #{sq_git_dir} show --no-show-signature --format=format:%cd --date=short`.lines.first.strip
|
103
103
|
end
|
104
104
|
else
|
105
105
|
if use_local_git
|
@@ -139,7 +139,7 @@ module GitVersionBump
|
|
139
139
|
EOF
|
140
140
|
|
141
141
|
log_file.close
|
142
|
-
system("git log --format='# %h %s' #{prev_tag}..HEAD >>#{log_file.path}")
|
142
|
+
system("git log --no-show-signature --format='# %h %s' #{prev_tag}..HEAD >>#{log_file.path}")
|
143
143
|
|
144
144
|
pre_hash = Digest::SHA1.hexdigest(File.read(log_file.path))
|
145
145
|
system("git config -e -f #{log_file.path}")
|
@@ -157,8 +157,8 @@ module GitVersionBump
|
|
157
157
|
system("git tag -a -m 'Version v#{v}' v#{v}")
|
158
158
|
end
|
159
159
|
|
160
|
-
system("git push
|
161
|
-
system("git push --tags
|
160
|
+
system("git push > #{DEVNULL} 2>&1")
|
161
|
+
system("git push --tags > #{DEVNULL} 2>&1")
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -196,10 +196,9 @@ module GitVersionBump
|
|
196
196
|
"GVB.commit_date_version(use_local_git=true) called, but git isn't installed"
|
197
197
|
end
|
198
198
|
|
199
|
-
sq_git_dir =
|
199
|
+
sq_git_dir = shell_quoted_string(Dir.pwd)
|
200
200
|
else
|
201
|
-
|
202
|
-
sq_git_dir = "'" + (File.dirname(caller_file) rescue nil || Dir.pwd).gsub("'", "'\\''") + "'"
|
201
|
+
sq_git_dir = shell_quoted_string((File.dirname(caller_file) rescue nil || Dir.pwd))
|
203
202
|
end
|
204
203
|
|
205
204
|
commit_dates = `git -C #{sq_git_dir} log --format=%at`.
|
@@ -224,21 +223,21 @@ module GitVersionBump
|
|
224
223
|
|
225
224
|
# Are we in a git repo with no tags? If so, dump out our
|
226
225
|
# super-special version and be done with it.
|
227
|
-
system("git -C #{sq_git_dir} status
|
226
|
+
system("git -C #{sq_git_dir} status > #{DEVNULL} 2>&1")
|
228
227
|
$? == 0 ? "0.0.0.1.ENOCOMMITS" : gem_version(use_local_git)
|
229
228
|
end
|
230
229
|
|
231
230
|
private
|
232
231
|
|
233
232
|
def self.git_available?
|
234
|
-
system("git --version
|
233
|
+
system("git --version > #{DEVNULL} 2>&1")
|
235
234
|
|
236
235
|
$? == 0
|
237
236
|
end
|
238
237
|
|
239
238
|
def self.dirty_tree?
|
240
239
|
# Are we in a dirty, dirty tree?
|
241
|
-
system("! git diff --no-ext-diff --quiet --exit-code 2
|
240
|
+
system("! git diff --no-ext-diff --quiet --exit-code 2> #{DEVNULL} || ! git diff-index --cached --quiet HEAD 2> #{DEVNULL}")
|
242
241
|
|
243
242
|
$? == 0
|
244
243
|
end
|
@@ -262,7 +261,7 @@ module GitVersionBump
|
|
262
261
|
# that contains the caller's file.
|
263
262
|
Gem.loaded_specs.values.each do |spec|
|
264
263
|
search_dirs = spec.require_paths.map { |d| "#{spec.full_gem_path}/#{d}" } +
|
265
|
-
[File.join(spec.
|
264
|
+
[File.join(spec.full_gem_path, spec.bindir)]
|
266
265
|
search_dirs.map! do |d|
|
267
266
|
begin
|
268
267
|
Pathname(d).realpath.to_s
|
@@ -301,6 +300,18 @@ module GitVersionBump
|
|
301
300
|
end
|
302
301
|
end
|
303
302
|
end
|
303
|
+
|
304
|
+
def self.shell_quoted_string(dir_string)
|
305
|
+
if Gem.win_platform?
|
306
|
+
return "\"#{dir_string}\""
|
307
|
+
else
|
308
|
+
# Shell Quoted, for your convenience
|
309
|
+
return "'#{dir_string.gsub("'", "'\\''")}'"
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
private_class_method :shell_quoted_string
|
314
|
+
|
304
315
|
end
|
305
316
|
|
306
317
|
GVB = GitVersionBump unless defined? GVB
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github-release
|
@@ -103,9 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.7.7
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Manage your app version entirely via git tags
|
110
110
|
test_files: []
|
111
|
-
has_rdoc:
|