Class: Pantograph::Actions::EnsureGitStatusCleanAction

Inherits:
Pantograph::Action show all
Defined in:
pantograph/lib/pantograph/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 Pantograph::Action

Pantograph::Action::AVAILABLE_CATEGORIES, Pantograph::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Pantograph::Action

action_name, authors, 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



39
40
41
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 39

def self.author
  ['lmirosevic', 'antondomashnev', 'johnknapprs']
end

.available_optionsObject



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

def self.available_options
  []
end

.categoryObject



56
57
58
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 56

def self.category
  :source_control
end

.descriptionObject



26
27
28
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 26

def self.description
  'Raises error if there are uncommitted git changes'
end

.detailsObject



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

def self.details
end

.example_codeObject



43
44
45
46
47
48
49
50
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 43

def self.example_code
  [
    'before_all do
       # Prevent pantograph from running lanes when git is in a dirty state
       ensure_git_status_clean
     end'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



60
61
62
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 60

def self.is_supported?(platform)
  true
end

.outputObject



33
34
35
36
37
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 33

def self.output
  [
    ['ENSURE_GIT_STATUS_CLEAN', 'Returns `true` if status clean when executed']
  ]
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'pantograph/lib/pantograph/actions/ensure_git_status_clean.rb', line 9

def self.run(params)
  repo_status = Helper::Git.repo_status

  if repo_status.empty?
    UI.success('Git status is clean, all good! 💪')
    Actions.lane_context[SharedValues::ENSURE_GIT_STATUS_CLEAN] = true
  else
    error_message = [
      'Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.',
      'Uncommitted changes:',
      repo_status
    ].join("\n")

    UI.user_error!(error_message)
  end
end