Class: Overview::AppVersion
- Inherits:
-
Object
- Object
- Overview::AppVersion
- Defined in:
- lib/appversion/appversion.rb
Instance Method Summary collapse
Instance Method Details
#build_no ⇒ Object
74 75 76 |
# File 'lib/appversion/appversion.rb', line 74 def build_no CI.build_no end |
#suffix ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/appversion/appversion.rb', line 78 def suffix branch = Git.branch p "Branch = #{branch}." case branch when /develop/ suffix = '-develop' when /master/ suffix = '-master' when /feature*/ suffix = "-#{branch.split('/').last.downcase}" when /release*/ suffix = "-#{branch.split('/').last.downcase}" when /hotfix*/ suffix = "-#{branch.split('/').last.downcase}" else suffix = '-debug' end #special case for github releases if CI.tagged_build? p 'Tagged build, suppressing branch suffix.' suffix = '' end return suffix end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/appversion/appversion.rb', line 37 def to_s "#{version} (#{build_no})" end |
#version(semantic = false) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/appversion/appversion.rb', line 41 def version(semantic = false) version_suffix = CI.version_suffix if Git.installed? latest_tag = Git.tag if latest_tag == 'HEAD' commit_count = Git.commit_count clean_tag = '0.0.1' elsif latest_tag.empty? #not a git directory commit_count = 0 clean_tag = '0.0.1' else commit_count = Git.commit_count_since_tag(latest_tag) clean_tag = Git.clean_tag end #Only increment version after production release, so that we retain a single version during beta and RCs if commit_count == 0 || Release.is_pre_release?(latest_tag) short_version = clean_tag else short_version = clean_tag.increment_version end target = !version_suffix.empty? ? ":#{version_suffix.upcase}" : '' if semantic short_version else short_version + target + suffix end else $stderr.puts 'Git required, not installed.' exit 1 end end |