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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, available_options, lane_context, method_missing, other_action, return_value, sample_return_value, sh, step_text

Class Method Details

.authorObject



40
41
42
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 40

def self.author
  "lmirosevic"
end

.categoryObject



48
49
50
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 48

def self.category
  :source_control
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

.detailsObject



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

def self.details
  [
    'A sanity check to make sure you are working in a repo that is clean. Especially',
    'useful to put at the beginning of your Fastfile in the `before_all` block, if',
    'some of your other actions will touch your filesystem, do things to your git repo,',
    'or just as a general reminder to save your work. Also needed as a prerequisite for',
    'some other actions like `reset_git_repo`.'
  ].join("\n")
end

.example_codeObject



44
45
46
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 44

def self.example_code
  ['ensure_git_status_clean']
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/fastlane/actions/ensure_git_status_clean.rb', line 52

def self.is_supported?(platform)
  true
end

.outputObject



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

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
    UI.success('Git status is clean, all good! 💪')
    Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
  else
    UI.user_error!("Git repository is dirty! Please ensure the repo is in a clean state by commiting/stashing/discarding all changes first.")
  end
end