git-version-bump 0.18.0.7.g2e0c3c4 → 0.18.0.9.gdf2ea32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32795b930c87e8796ae34c50d42703165e8dc083d4fa4e6cd19763f49f71d78a
4
- data.tar.gz: bdf0755443972b724acb3be0cf0b677cc5a698f52533ec9afe8c47dd35ec5553
3
+ metadata.gz: 79a1a1154525f5c0f50020261fba1e295f985e3d2264335420b060c2c55a352b
4
+ data.tar.gz: c4aa9cfd65980d0d1024daf8806b4831acd8056d1a315d1c562e80fb87a58f9b
5
5
  SHA512:
6
- metadata.gz: 3e97d8fd061b44c0f841c435f303930eacf1834acfb555c3b69f5ab7cfc918b678fa452e4f5ce1b8b0b780d5f01546226791a0fa45ad6985fc252d7c9cd63d5e
7
- data.tar.gz: 82f01e33ed949be7ad11a544a24a44383e8f01896b67ff242c955287ea7ea51987e43c7afb9727afd026c63bce78bf0d06b3729016c8af5e4ca429d4ed832d53
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
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.platform = Gem::Platform::RUBY
12
12
  s.required_ruby_version = ">= 2.1.0"
13
13
 
14
- s.homepage = "http://theshed.hezmatt.org/git-version-bump"
14
+ s.homepage = "https://github.com/mpalmer/git-version-bump"
15
15
  s.summary = "Manage your app version entirely via git tags"
16
16
  s.authors = ["Matt Palmer"]
17
17
 
@@ -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 :repo_version
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 :repo_date
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.7.g2e0c3c4
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-01-11 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-release
@@ -85,7 +85,7 @@ files:
85
85
  - lib/git-version-bump.rb
86
86
  - lib/git-version-bump/rake-tasks.rb
87
87
  - lib/git-version-bump/version.rb
88
- homepage: http://theshed.hezmatt.org/git-version-bump
88
+ homepage: https://github.com/mpalmer/git-version-bump
89
89
  licenses: []
90
90
  metadata: {}
91
91
  post_install_message: