module Pantograph::Helper::Git

Public Class Methods

current_branch() click to toggle source

Returns the current git branch - can be replaced using the environment variable `GIT_BRANCH`

# File pantograph/lib/pantograph/helper/git_helper.rb, line 139
def self.current_branch
  return ENV['GIT_BRANCH'] if ENV['GIT_BRANCH'].to_s.length > 0 # set by Jenkins
  s = Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
  return s.to_s.strip if s.to_s.length > 0
  nil
rescue
  nil
end
is_git?() click to toggle source
# File pantograph/lib/pantograph/helper/git_helper.rb, line 156
def self.is_git?
  Actions.sh('git rev-parse HEAD', log: false)
  return true
rescue
  UI.user_error!("Not in a git repository.")
end
repo_clean?() click to toggle source
# File pantograph/lib/pantograph/helper/git_helper.rb, line 152
def self.repo_clean?
  repo_status.empty?
end
repo_status() click to toggle source
# File pantograph/lib/pantograph/helper/git_helper.rb, line 148
def self.repo_status
  Actions.sh('git status --porcelain')
end