class Fastlane::Actions::EnsureGitStatusCleanAction

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

def self.author

def self.author
  "lmirosevic"
end

def self.description

def self.description
  "Raises an exception if there are uncommited git changes"
end

def self.is_supported?(platform)

def self.is_supported?(platform)
  true
end

def self.output

def self.output
  [
    ['GIT_REPO_WAS_CLEAN_ON_START', 'Stores the fact that the git repo was clean at some point']
  ]
end

def self.run(params)

def self.run(params)
  repo_clean = `git status --porcelain`.empty?
  if repo_clean
    Helper.log.info 'Git status is clean, all good! 💪'.green
    Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
  else
    raise 'Git repository is dirty! Please ensure the repo is in a clean state by commiting/stashing/discarding all changes first.'.red
  end
end