git-version-bump 0.18.0.8.g580160f → 0.18.0.9.gdf2ea32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/git-version-bump.rb +28 -3
- 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: 79a1a1154525f5c0f50020261fba1e295f985e3d2264335420b060c2c55a352b
|
4
|
+
data.tar.gz: c4aa9cfd65980d0d1024daf8806b4831acd8056d1a315d1c562e80fb87a58f9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec061ff61f4a8e4e26c8b8bb119cbd3414d1015b79fd1649fb8307422dcd43e6deb5b392adb3be1ff21097fc85f41d582f99919b5ddf2d0926479bc2ee4bae8
|
7
|
+
data.tar.gz: 59661e2dbace2392afd6be097d399ac908cec1a6cbd3214bf57cf618d8a7530990fb59cd59199985f32bffcbe8b616077fd79ba67250150236cf225f2ee7bb51
|
data/README.md
CHANGED
@@ -141,6 +141,19 @@ commits to be detected then use the following configuration:
|
|
141
141
|
end
|
142
142
|
|
143
143
|
|
144
|
+
## Overriding the version
|
145
|
+
|
146
|
+
In very rare circumstances, while running in a git repo, you may wish to explicitly set the version or date returned by `GVB.version` or `GVB.date`, respectively.
|
147
|
+
This can be done by setting the repo's `versionBump.versionOverride` or `versionBump.dateOverride` config values, like so:
|
148
|
+
|
149
|
+
```bash
|
150
|
+
git config versionBump.versionOverride 1.2.3
|
151
|
+
git config versionBump.dateOverride 1970-01-01
|
152
|
+
```
|
153
|
+
|
154
|
+
Note that whatever you set those values to is used without validity checking; if you set it to something weird, you'll get weird results.
|
155
|
+
|
156
|
+
|
144
157
|
# Contributing
|
145
158
|
|
146
159
|
Send your pull requests to the [Github
|
data/lib/git-version-bump.rb
CHANGED
@@ -25,7 +25,7 @@ module GitVersionBump
|
|
25
25
|
repo_version(true, include_lite_tags)
|
26
26
|
else
|
27
27
|
gem_version || repo_version(false, include_lite_tags)
|
28
|
-
end
|
28
|
+
end.tap { |v| p :GVB_VERSION, v if debug? }
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.major_version(use_local_dir=false, include_lite_tags=false)
|
@@ -236,6 +236,11 @@ module GitVersionBump
|
|
236
236
|
end
|
237
237
|
private_class_method :try_command
|
238
238
|
|
239
|
+
def self.run_git(git_args, desc, use_local_dir)
|
240
|
+
run_command(["git", "-C", git_dir(use_local_dir).to_s] + git_args, desc)
|
241
|
+
end
|
242
|
+
private_class_method :run_git
|
243
|
+
|
239
244
|
def self.caller_file
|
240
245
|
# Who called us? Because this method gets called from other methods
|
241
246
|
# within this file, we can't just look at Gem.location_of_caller, but
|
@@ -298,6 +303,16 @@ module GitVersionBump
|
|
298
303
|
private_class_method :gem_version
|
299
304
|
|
300
305
|
def self.repo_version(use_local_dir, include_lite_tags)
|
306
|
+
begin
|
307
|
+
run_git(["config", "versionBump.versionOverride"], "getting versionOverride", use_local_dir).chomp
|
308
|
+
rescue CommandFailure => ex
|
309
|
+
p :NO_OVERRIDE_VERSION, [ex.class, ex.message] if debug?
|
310
|
+
repo_version_from_tag(use_local_dir, include_lite_tags)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
private_class_method :repo_version
|
314
|
+
|
315
|
+
def self.repo_version_from_tag(use_local_dir, include_lite_tags)
|
301
316
|
git_cmd = ["git", "-C", git_dir(use_local_dir).to_s, "describe", "--dirty=.1.dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}", "--match=#{VERSION_TAG_GLOB}"]
|
302
317
|
git_cmd << "--tags" if include_lite_tags
|
303
318
|
|
@@ -316,9 +331,19 @@ module GitVersionBump
|
|
316
331
|
end
|
317
332
|
end
|
318
333
|
end
|
319
|
-
private_class_method :
|
334
|
+
private_class_method :repo_version_from_tag
|
320
335
|
|
321
336
|
def self.repo_date(use_local_dir, include_lite_tags)
|
337
|
+
begin
|
338
|
+
run_git(["config", "versionBump.dateOverride"], "getting dateOverride", use_local_dir).chomp
|
339
|
+
rescue CommandFailure => ex
|
340
|
+
p :NO_OVERRIDE_DATE, [ex.class, ex.message] if debug?
|
341
|
+
repo_date_from_commit(use_local_dir, include_lite_tags)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
private_class_method :repo_date
|
345
|
+
|
346
|
+
def self.repo_date_from_commit(use_local_dir, include_lite_tags)
|
322
347
|
if dirty_tree?(git_dir(use_local_dir))
|
323
348
|
Time.now.strftime("%F")
|
324
349
|
else
|
@@ -328,7 +353,7 @@ module GitVersionBump
|
|
328
353
|
rescue CommandFailure
|
329
354
|
raise VersionUnobtainable, "Could not get commit date from git repository at #{git_dir(use_local_dir)}"
|
330
355
|
end
|
331
|
-
private_class_method :
|
356
|
+
private_class_method :repo_date_from_commit
|
332
357
|
|
333
358
|
def self.git_dir(use_local_dir = false)
|
334
359
|
if use_local_dir
|
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.18.0.
|
4
|
+
version: 0.18.0.9.gdf2ea32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github-release
|