class Pantograph::Actions::EnsureGitStatusCleanAction

Raises an exception and stop the lane execution if the repo is not in a clean state

Public Class Methods

author() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 39
def self.author
  ['lmirosevic', 'antondomashnev', 'johnknapprs']
end
available_options() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 52
def self.available_options
  []
end
category() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 56
def self.category
  :source_control
end
description() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 26
def self.description
  'Raises error if there are uncommitted git changes'
end
details() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 30
def self.details
end
example_code() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 43
def self.example_code
  [
    'before_all do
       # Prevent pantograph from running lanes when git is in a dirty state
       ensure_git_status_clean
     end'
  ]
end
is_supported?(platform) click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 60
def self.is_supported?(platform)
  true
end
output() click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 33
def self.output
  [
    ['ENSURE_GIT_STATUS_CLEAN', 'Returns `true` if status clean when executed']
  ]
end
run(params) click to toggle source
# File pantograph/lib/pantograph/actions/ensure_git_status_clean.rb, line 9
def self.run(params)
  repo_status = Helper::Git.repo_status

  if repo_status.empty?
    UI.success('Git status is clean, all good! 💪')
    Actions.lane_context[SharedValues::ENSURE_GIT_STATUS_CLEAN] = true
  else
    error_message = [
      'Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.',
      'Uncommitted changes:',
      repo_status
    ].join("\n")

    UI.user_error!(error_message)
  end
end