Class: Fastlane::Actions::HgEnsureCleanStatusAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/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, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, available_options, deprecated_notes, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



33
34
35
36
# File 'fastlane/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 'fastlane/lib/fastlane/actions/hg_ensure_clean_status.rb', line 48

def self.category
  :source_control
end

.descriptionObject



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

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

.detailsObject



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

def self.details
  "Along the same lines as the [ensure_git_status_clean](https://docs.fastlane.tools/actions/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 'fastlane/lib/fastlane/actions/hg_ensure_clean_status.rb', line 42

def self.example_code
  [
    'hg_ensure_clean_status'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



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

def self.is_supported?(platform)
  true
end

.outputObject



27
28
29
30
31
# File 'fastlane/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 'fastlane/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 committing/stashing/discarding all changes first.')
  end
end