Class: Fastlane::Actions::HgEnsureCleanStatusAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/hg_ensure_clean_status.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



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

def self.author
  # credits to lmirosevic for original git version
  "sjrmanning"
end

.categoryObject



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

def self.category
  :source_control
end

.descriptionObject



19
20
21
# File 'lib/fastlane/actions/hg_ensure_clean_status.rb', line 19

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

.detailsObject



23
24
25
# File 'lib/fastlane/actions/hg_ensure_clean_status.rb', line 23

def self.details
  "Along the same lines as the [`ensure_git_status_clean`](#ensure_git_status_clean) action, this is a sanity check to ensure the working mercurial repo is clean. Especially useful to put at the beginning of your Fastfile in the `before_all` block."
end

.example_codeObject



42
43
44
45
46
# File 'lib/fastlane/actions/hg_ensure_clean_status.rb', line 42

def self.example_code
  [
    'hg_ensure_clean_status'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/fastlane/actions/hg_ensure_clean_status.rb', line 38

def self.is_supported?(platform)
  true
end

.outputObject



27
28
29
30
31
# File 'lib/fastlane/actions/hg_ensure_clean_status.rb', line 27

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

.run(params) ⇒ Object



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

def self.run(params)
  repo_clean = `hg status`.empty?

  if repo_clean
    UI.success('Mercurial status is clean, all good! 😎')
    Actions.lane_context[SharedValues::HG_REPO_WAS_CLEAN_ON_START] = true
  else
    UI.user_error!('Mercurial repository is dirty! Please ensure the repo is in a clean state by commiting/stashing/discarding all changes first.')
  end
end