Module: Pantograph::Helper::Git

Defined in:
pantograph/lib/pantograph/helper/git_helper.rb

Class Method Summary collapse

Class Method Details

.current_branchObject

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



139
140
141
142
143
144
145
146
# 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?Boolean

Returns:



156
157
158
159
160
161
# 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?Boolean

Returns:



152
153
154
# File 'pantograph/lib/pantograph/helper/git_helper.rb', line 152

def self.repo_clean?
  repo_status.empty?
end

.repo_statusObject



148
149
150
# File 'pantograph/lib/pantograph/helper/git_helper.rb', line 148

def self.repo_status
  Actions.sh('git status --porcelain')
end