Class: Tagging::AppVersion
- Inherits:
-
Object
- Object
- Tagging::AppVersion
- Defined in:
- lib/tagging/app_version.rb
Constant Summary collapse
- @@default_commit_message =
'versioning by CI'
Class Method Summary collapse
- .commit_and_push(project_directory = nil, msg = nil, &block) ⇒ Object
- .increment_and_push ⇒ Object
- .increment_version ⇒ Object
- .init_version_file ⇒ Object
- .version ⇒ Object
- .version_format_valid?(v) ⇒ Boolean
Class Method Details
.commit_and_push(project_directory = nil, msg = nil, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/tagging/app_version.rb', line 32 def self.commit_and_push(project_directory = nil, msg = nil, &block) g=Git.open(project_directory || Dir.pwd, :log=>Logger.new(STDOUT)) g.add_tag(self.version, nil, message: @@default_commit_message) g.push('origin', "refs/tags/#{self.version}", f: true) end |
.increment_and_push ⇒ Object
23 24 25 26 |
# File 'lib/tagging/app_version.rb', line 23 def self.increment_and_push self.increment_version self.commit_and_push end |
.increment_version ⇒ Object
28 29 30 |
# File 'lib/tagging/app_version.rb', line 28 def self.increment_version @@version = self.version.next end |
.init_version_file ⇒ Object
19 20 21 |
# File 'lib/tagging/app_version.rb', line 19 def self.init_version_file initial_version = 'v0.0.1-00' end |
.version ⇒ Object
9 10 11 12 13 |
# File 'lib/tagging/app_version.rb', line 9 def self.version @@version ||= `git -C #{Dir.pwd} describe --tags $(git -C #{Dir.pwd} for-each-ref refs/tags --sort=-taggerdate --format='%(objectname)' --count=1)`.chomp @@version = self.init_version_file unless self.version_format_valid?(@@version) @@version end |
.version_format_valid?(v) ⇒ Boolean
15 16 17 |
# File 'lib/tagging/app_version.rb', line 15 def self.version_format_valid?(v) (v && v =~ /^v\d+\.\d+\.\d+-[\.\d+]+$/) end |