git-lite-version-bump 0.17.1 → 0.17.2
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 +4 -4
- data/lib/git-version-bump.rb +24 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11b1d0035cce0dcc1c4713db85c0b695c945200a625d281b24c50fd2e5fbddb9
|
4
|
+
data.tar.gz: 9826f50499d603317b53640bd772bba95486b1180b1fa8d12bfe64cf053c3fb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a7978746a84b9e614bb1904be4ccbe1790b2f1f0a1f1b6947578418d2341217691bac76af8aeb02dcd9f490110e039fcadc39c5e95ea894eb5abc9b2fadd482
|
7
|
+
data.tar.gz: 53ecbb6f8ea367f4273e6a0e78ddd181189fe4ebf4b8a41d48ca92992279380bffcb41273f0a6a32fc33cea0d603c806f97e65c0c992ccd87c50234242d66f27
|
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
|
+
VERSION_TAG_GLOB = 'v[0.9]*.[0-9]*.*[0-9]'
|
9
|
+
|
8
10
|
DEVNULL = Gem.win_platform? ? "NUL" : "/dev/null"
|
9
11
|
|
10
12
|
def self.version(use_local_git=false, include_lite_tags=false)
|
@@ -19,7 +21,7 @@ module GitVersionBump
|
|
19
21
|
sq_git_dir = shell_quoted_string((File.dirname(caller_file) rescue nil || Dir.pwd))
|
20
22
|
end
|
21
23
|
|
22
|
-
git_cmd = "git -C #{sq_git_dir} describe --dirty='.1.dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}' --match='
|
24
|
+
git_cmd = "git -C #{sq_git_dir} describe --dirty='.1.dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}' --match='#{VERSION_TAG_GLOB}'"
|
23
25
|
git_cmd << " --tags" if include_lite_tags
|
24
26
|
|
25
27
|
git_ver = `#{git_cmd} 2> #{DEVNULL}`.
|
@@ -34,11 +36,13 @@ module GitVersionBump
|
|
34
36
|
# git failed us; we're either not in a git repo or else we've never
|
35
37
|
# tagged anything before.
|
36
38
|
|
37
|
-
# Are we in a git repo with no tags? If so,
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
# Are we in a git repo with no tags? If so, try to use the gemspec
|
40
|
+
# and if that fails then abort
|
41
|
+
begin
|
42
|
+
return gem_version(use_local_git)
|
43
|
+
rescue VersionUnobtainable
|
44
|
+
return "0.0.0.1.ENOTAG"
|
45
|
+
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def self.major_version(use_local_git=false, include_lite_tags=false)
|
@@ -98,11 +102,11 @@ module GitVersionBump
|
|
98
102
|
if $? == 0
|
99
103
|
# Yes, we're in git.
|
100
104
|
|
101
|
-
if dirty_tree?
|
105
|
+
if dirty_tree?(sq_git_dir)
|
102
106
|
return Time.now.strftime("%F")
|
103
107
|
else
|
104
108
|
# Clean tree. Date of last commit is needed.
|
105
|
-
return `git -C #{sq_git_dir} show --no-show-signature --format=format:%cd --date=short`.lines.first
|
109
|
+
return `git -C #{sq_git_dir} show --no-show-signature --format=format:%cd --date=short`.lines.first&.strip
|
106
110
|
end
|
107
111
|
else
|
108
112
|
if use_local_git
|
@@ -127,7 +131,7 @@ module GitVersionBump
|
|
127
131
|
if release_notes
|
128
132
|
# We need to find the tag before this one, so we can list all the commits
|
129
133
|
# between the two. This is not a trivial operation.
|
130
|
-
git_cmd =
|
134
|
+
git_cmd = "git describe --match '#{VERSION_TAG_GLOB}' --always"
|
131
135
|
git_cmd << ' --tags' if include_lite_tags
|
132
136
|
prev_tag = `#{git_cmd}`.strip.gsub(/-\d+-g[0-9a-f]+$/, '')
|
133
137
|
|
@@ -226,10 +230,13 @@ module GitVersionBump
|
|
226
230
|
# git failed us; either we're not in a git repo or else it's a git
|
227
231
|
# repo that's not got any commits.
|
228
232
|
|
229
|
-
# Are we in a git repo with no
|
230
|
-
#
|
231
|
-
|
232
|
-
|
233
|
+
# Are we in a git repo with no commits? If so, try to use the gemspec
|
234
|
+
# and if that fails then abort
|
235
|
+
begin
|
236
|
+
return gem_version(use_local_git)
|
237
|
+
rescue VersionUnobtainable
|
238
|
+
return "0.0.0.1.ENOCOMMITS"
|
239
|
+
end
|
233
240
|
end
|
234
241
|
|
235
242
|
private
|
@@ -240,11 +247,9 @@ module GitVersionBump
|
|
240
247
|
$? == 0
|
241
248
|
end
|
242
249
|
|
243
|
-
def self.dirty_tree?
|
250
|
+
def self.dirty_tree?(sq_git_dir='.')
|
244
251
|
# Are we in a dirty, dirty tree?
|
245
|
-
system("
|
246
|
-
|
247
|
-
$? == 0
|
252
|
+
!system("git -C #{sq_git_dir} diff --no-ext-diff --quiet --exit-code 2> #{DEVNULL}") || !("git -C #{sq_git_dir} diff-index --cached --quiet HEAD 2> #{DEVNULL}")
|
248
253
|
end
|
249
254
|
|
250
255
|
def self.caller_file
|
@@ -252,14 +257,9 @@ module GitVersionBump
|
|
252
257
|
# within this file, we can't just look at Gem.location_of_caller, but
|
253
258
|
# instead we need to parse the caller stack ourselves to find which
|
254
259
|
# gem we're trying to version all over.
|
255
|
-
#
|
256
|
-
# Caller returns paths of the form `/path/to/file:100:in method...` on *nix
|
257
|
-
# and `C:\path\to\file:in method...` on Windows. Splitting on colon isn't
|
258
|
-
# reliable since the Windows path has a colon at the beginning, split on :num:
|
259
|
-
# instead since that will always be there no matter the platform.
|
260
260
|
Pathname(
|
261
|
-
|
262
|
-
map
|
261
|
+
caller_locations.
|
262
|
+
map(&:path).
|
263
263
|
find { |l| l != __FILE__ }
|
264
264
|
).realpath.to_s rescue nil
|
265
265
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-lite-version-bump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github-release
|