Class: Fastlane::Actions::EnsureGitStatusCleanAction
Overview
Raises an exception and stop the lane execution if the repo is not in a clean state
Constant Summary
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Class Method Summary
collapse
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
.author ⇒ Object
47
48
49
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 47
def self.author
["lmirosevic", "antondomashnev"]
end
|
.available_options ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 55
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :show_uncommitted_changes,
env_name: "FL_ENSURE_GIT_STATUS_CLEAN_SHOW_UNCOMMITTED_CHANGES",
description: "The flag whether to show uncommitted changes if the repo is dirty",
optional: true,
default_value: false,
is_string: false),
FastlaneCore::ConfigItem.new(key: :show_diff,
env_name: "FL_ENSURE_GIT_STATUS_CLEAN_SHOW_DIFF",
description: "The flag whether to show the git diff if the repo is dirty",
optional: true,
default_value: false,
is_string: false)
]
end
|
.category ⇒ Object
72
73
74
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 72
def self.category
:source_control
end
|
.description ⇒ Object
27
28
29
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 27
def self.description
"Raises an exception if there are uncommitted git changes"
end
|
.details ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 31
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_code ⇒ Object
51
52
53
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 51
def self.example_code
['ensure_git_status_clean']
end
|
.is_supported?(platform) ⇒ Boolean
76
77
78
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 76
def self.is_supported?(platform)
true
end
|
.output ⇒ Object
41
42
43
44
45
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 41
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
19
20
21
22
23
24
25
|
# File 'fastlane/lib/fastlane/actions/ensure_git_status_clean.rb', line 9
def self.run(params)
repo_status = Actions.sh("git status --porcelain")
repo_clean = repo_status.empty?
if repo_clean
UI.success('Git status is clean, all good! 💪')
Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
else
error_message = "Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first."
error_message += "\nUncommitted changes:\n#{repo_status}" if params[:show_uncommitted_changes]
if params[:show_diff]
repo_diff = Actions.sh("git diff")
error_message += "\nGit diff: \n#{repo_diff}"
end
UI.user_error!(error_message)
end
end
|