class Stax::Git
Public Class Methods
branch()
click to toggle source
# File lib/stax/git.rb, line 7 def self.branch @_branch ||= `git symbolic-ref --short HEAD`.chomp end
origin_sha()
click to toggle source
# File lib/stax/git.rb, line 28 def self.origin_sha @_origin_sha ||= `git rev-parse origin/#{branch}`.chomp end
origin_url()
click to toggle source
# File lib/stax/git.rb, line 19 def self.origin_url @_origin_url ||= `git config --get remote.origin.url`.chomp end
repo()
click to toggle source
path like org/repo
# File lib/stax/git.rb, line 24 def self.repo @_repo ||= GitCloneUrl.parse(origin_url)&.path&.sub(/\.git$/, '') end
sha()
click to toggle source
# File lib/stax/git.rb, line 11 def self.sha @_sha ||= `git rev-parse HEAD`.chomp end
short_sha()
click to toggle source
# File lib/stax/git.rb, line 15 def self.short_sha @_short_sha ||= self.sha.slice(0,7) end
tag(tag, sha)
click to toggle source
tag the sha and push to origin
# File lib/stax/git.rb, line 45 def self.tag(tag, sha) system "git tag #{tag} #{sha} && git push origin #{tag} --quiet" end
toplevel()
click to toggle source
# File lib/stax/git.rb, line 32 def self.toplevel @_toplevel ||= `git rev-parse --show-toplevel`.chomp end
uncommitted_changes?()
click to toggle source
# File lib/stax/git.rb, line 36 def self.uncommitted_changes? !`git diff --shortstat`.chomp.empty? end
unpushed_commits?()
click to toggle source
# File lib/stax/git.rb, line 40 def self.unpushed_commits? sha != origin_sha end
Public Instance Methods
branch()
click to toggle source
# File lib/stax/git.rb, line 51 def branch puts Git.branch end
sha()
click to toggle source
# File lib/stax/git.rb, line 56 def sha puts Git.sha end