class Git

Public Class Methods

ahead_of_branch_by(branch) click to toggle source
# File lib/mark_version/git.rb, line 26
def self.ahead_of_branch_by(branch)
  `git rev-list #{branch}..HEAD --count`.chomp
end
ahead_of_release_by() click to toggle source
# File lib/mark_version/git.rb, line 22
def self.ahead_of_release_by
  `git rev-list #{closest_release_branch}..HEAD --count`.chomp
end
ahead_of_version?(branch) click to toggle source
# File lib/mark_version/git.rb, line 10
def self.ahead_of_version?(branch)
  self.ahead_of_version_by(branch).to_i > 0
end
ahead_of_version_by(branch) click to toggle source
# File lib/mark_version/git.rb, line 6
def self.ahead_of_version_by(branch)
  `git rev-list #{self.last_version_commit}..#{branch} --count`.chomp
end
branch() click to toggle source
# File lib/mark_version/git.rb, line 2
def self.branch
  `git rev-parse --abbrev-ref HEAD`.chomp
end
closest_release_branch() click to toggle source
# File lib/mark_version/git.rb, line 30
def self.closest_release_branch
  branch = nil
  distance = nil

  MarkVersionConfig.new.release_branches.each do |branch|
    if distance.nil? || ahead_of_branch_by(branch) < distance
      branch = branch
      distance = ahead_of_branch_by(branch)
    end
  end

  branch || 'master'
end
commit(version) click to toggle source
# File lib/mark_version/git.rb, line 61
def self.commit(version)
  `git add VERSION`
  `git commit -m "To version #{version}"`
end
commit_and_tag(version) click to toggle source
# File lib/mark_version/git.rb, line 56
def self.commit_and_tag(version)
  commit(version)
  tag(version)
end
current_ahead_by() click to toggle source
# File lib/mark_version/git.rb, line 18
def self.current_ahead_by
  ahead_of_version_by('HEAD')
end
current_ahead_of_version?() click to toggle source
# File lib/mark_version/git.rb, line 14
def self.current_ahead_of_version?
  ahead_of_version?('HEAD')
end
last_version_commit() click to toggle source
# File lib/mark_version/git.rb, line 52
def self.last_version_commit
  `git log --format="%h" VERSION | head -n 1`.chomp
end
on_release_branch?() click to toggle source
# File lib/mark_version/git.rb, line 44
def self.on_release_branch?
  MarkVersionConfig.new.release_branches.include?(branch)
end
push() click to toggle source
# File lib/mark_version/git.rb, line 70
def self.push
  `git push origin --tags`
end
short_hash() click to toggle source
# File lib/mark_version/git.rb, line 48
def self.short_hash
  `git rev-parse --short HEAD`.chomp
end
tag(version) click to toggle source
# File lib/mark_version/git.rb, line 66
def self.tag(version)
  `git tag #{version} -a -m "Release version #{version}"`
end