Class: ThorSCMVersion::GitVersion
- Inherits:
-
ScmVersion
- Object
- ScmVersion
- ThorSCMVersion::GitVersion
- Defined in:
- lib/thor-scmversion/git_version.rb
Constant Summary
Constants inherited from ScmVersion
ScmVersion::VERSION_FILENAME, ScmVersion::VERSION_FORMAT
Instance Attribute Summary
Attributes inherited from ScmVersion
#build, #major, #minor, #patch, #prerelease
Class Method Summary collapse
Instance Method Summary collapse
-
#auto_bump(options) ⇒ Object
Check the commit messages to see what type of bump is required.
- #tag ⇒ Object
Methods inherited from ScmVersion
#<=>, #bump!, from_path, from_tag, #initialize, #reset_for, #to_s, #write_version
Constructor Details
This class inherits a constructor from ThorSCMVersion::ScmVersion
Class Method Details
.all_from_path(path) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/thor-scmversion/git_version.rb', line 6 def all_from_path(path) Dir.chdir(path) do = Open3.popen3("git tag") { |stdin, stdout, stderr| stdout.read }.split(/\n/) .select { |tag| tag.match(ScmVersion::VERSION_FORMAT) } .collect { |tag| from_tag(tag) } .select { |tag| contained_in_current_branch?(tag) }.sort.reverse end end |
.contained_in_current_branch?(tag) ⇒ Boolean
15 16 17 |
# File 'lib/thor-scmversion/git_version.rb', line 15 def contained_in_current_branch?(tag) ShellUtils.sh("git branch --contains #{tag}") =~ /\*/ end |
.retrieve_tags ⇒ Object
19 20 21 |
# File 'lib/thor-scmversion/git_version.rb', line 19 def ShellUtils.sh("git fetch --all") end |
Instance Method Details
#auto_bump(options) ⇒ Object
Check the commit messages to see what type of bump is required
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/thor-scmversion/git_version.rb', line 34 def auto_bump() last_tag = self.class.from_path.to_s logs = ShellUtils.sh "git log --abbrev-commit --format=oneline #{last_tag}.." guess = if logs =~ /\[major\]|\#major/i :major elsif logs =~ /\[minor\]|\#minor/i :minor elsif logs =~ /\[prerelease\s?(#{Prerelease::TYPE_FORMAT})?\]|\#prerelease\-?(#{Prerelease::TYPE_FORMAT})?/ prerelease_type = $1 || $2 :prerelease elsif logs =~ /\[patch\]|\#patch/i :patch else [:default] or :build end bump!(guess, prerelease_type: prerelease_type) end |
#tag ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/thor-scmversion/git_version.rb', line 24 def tag begin ShellUtils.sh "git tag -a -m \"Version #{self}\" #{self}" rescue => e raise GitTagDuplicateError.new(self.to_s) end ShellUtils.sh "git push --tags || true" end |