Class: Fastlane::Actions::EnsureGitStatusCleanAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/ensure_git_status_clean.rb

Overview

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

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, available_options, details, sh, step_text

Class Method Details

.authorObject



30
31
32
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 30

def self.author
  "lmirosevic"
end

.descriptionObject



20
21
22
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 20

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 34

def self.is_supported?(platform)
  true
end

.outputObject



24
25
26
27
28
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 24

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

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 9

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