Class: Fastlane::Actions::ConfigureUpdateAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::ConfigureUpdateAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb
Class Method Summary collapse
- .absolute_secret_store_path ⇒ Object
- .authors ⇒ Object
-
.checkout_branch(branch_name) ⇒ Object
Switch to the given branch, but don’t ensure that it’s up-to-date – that’s for another step.
- .configure_file_commits_behind_repo ⇒ Object
- .configure_file_is_behind_repo ⇒ Object
- .current_branch ⇒ Object
- .current_hash ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .get_branches ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .prompt_to_switch_branches ⇒ Object
- .prompt_to_update_configure_file_to_most_recent_hash ⇒ Object
- .prompt_to_update_to_most_recent_version ⇒ Object
- .repo_commits_behind_remote ⇒ Object
- .repo_is_ahead_of_remote ⇒ Object
- .repo_is_behind_remote ⇒ Object
- .run(params = {}) ⇒ Object
-
.update_branch ⇒ Object
Ensure that the local secrets respository is up to date.
- .update_configure_file ⇒ Object
Class Method Details
.absolute_secret_store_path ⇒ Object
116 117 118 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 116 def self.absolute_secret_store_path Fastlane::Helper::FilesystemHelper.secret_store_dir end |
.authors ⇒ Object
124 125 126 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 124 def self. ['Automattic'] end |
.checkout_branch(branch_name) ⇒ Object
Switch to the given branch, but don’t ensure that it’s up-to-date – that’s for another step
107 108 109 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 107 def self.checkout_branch(branch_name) sh("cd '#{absolute_secret_store_path}' && git checkout '#{branch_name}'") end |
.configure_file_commits_behind_repo ⇒ Object
95 96 97 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 95 def self.configure_file_commits_behind_repo Fastlane::Helper::ConfigureHelper.configure_file_commits_behind_repo end |
.configure_file_is_behind_repo ⇒ Object
91 92 93 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 91 def self.configure_file_is_behind_repo Fastlane::Helper::ConfigureHelper.configure_file_is_behind_local end |
.current_branch ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 67 def self.current_branch Fastlane::Helper::ConfigureHelper.repo_branch_name end |
.current_hash ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 71 def self.current_hash Fastlane::Helper::ConfigureHelper.repo_commit_hash end |
.description ⇒ Object
120 121 122 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 120 def self.description 'Ensure that the local secrets repository is up to date.' end |
.details ⇒ Object
128 129 130 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 128 def self.details 'Ensure that the local secrets repository is up to date, and lets you test alternative branches.' end |
.get_branches ⇒ Object
99 100 101 102 103 104 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 99 def self.get_branches branches = sh("cd #{absolute_secret_store_path} && git branch -r") branches.split("\n") .map { |s| s.strip!.split('/')[1] } .reject { |s| s.include? 'HEAD' } end |
.is_supported?(platform) ⇒ Boolean
132 133 134 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 132 def self.is_supported?(platform) true end |
.prompt_to_switch_branches ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 45 def self.prompt_to_switch_branches branch_name_to_display = current_branch.nil? ? current_hash : current_branch if UI.confirm("The current Mobile Secrets branch is `#{branch_name_to_display}`. Would you like to switch branches?") new_branch = UI.select("Select the branch you'd like to switch to: ", get_branches) checkout_branch(new_branch) update_configure_file elsif current_branch.nil? UI.user_error!('The local secrets store is in a deatched HEAD state. Please check out a branch and try again.') end end |
.prompt_to_update_configure_file_to_most_recent_hash ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 63 def self.prompt_to_update_configure_file_to_most_recent_hash update_configure_file if UI.confirm("The `.configure` file is #{configure_file_commits_behind_repo} commit hash(es) behind the repo. Would you like to update it?") end |
.prompt_to_update_to_most_recent_version ⇒ Object
56 57 58 59 60 61 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 56 def self.prompt_to_update_to_most_recent_version return unless UI.confirm("The current branch is #{repo_commits_behind_remote} commit(s) behind. Would you like to update it?") update_branch update_configure_file end |
.repo_commits_behind_remote ⇒ Object
83 84 85 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 83 def self.repo_commits_behind_remote Fastlane::Helper::ConfigureHelper.repo_commits_behind_remote end |
.repo_is_ahead_of_remote ⇒ Object
79 80 81 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 79 def self.repo_is_ahead_of_remote Fastlane::Helper::ConfigureHelper.repo_is_ahead_of_remote end |
.repo_is_behind_remote ⇒ Object
87 88 89 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 87 def self.repo_is_behind_remote Fastlane::Helper::ConfigureHelper.repo_is_behind_remote end |
.run(params = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 10 def self.run(params = {}) prompt_to_switch_branches if repo_is_ahead_of_remote UI.user_error!("The local secrets store has changes that the remote repository doesn't.\ Please fix this issue before continuing") end prompt_to_update_to_most_recent_version if repo_is_behind_remote if configure_file_is_behind_repo prompt_to_update_configure_file_to_most_recent_hash else # Update configure file even if already update to date # This ensures the file format is up to date update_configure_file end # If there is no encryption key for the project, generate one if Fastlane::Helper::ConfigureHelper.project_encryption_key.nil? # If the user chose not to update the repo but there is no encryption key, throw an error UI.user_error!('The local secrets behind the remote but it is missing a keys.json entry for this project. Please update it to the latest commit.') if repo_is_behind_remote Fastlane::Helper::ConfigureHelper.update_project_encryption_key # Update the configure file to the new hash update_configure_file end Fastlane::Helper::ConfigureHelper.files_to_copy.each(&:update) UI.success "Configuration Secrets are up to date – don't forget to commit your changes to `.configure`." # Apply the changes that are now in the .configure file other_action.configure_apply end |
.update_branch ⇒ Object
Ensure that the local secrets respository is up to date
112 113 114 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 112 def self.update_branch sh("cd '#{absolute_secret_store_path}' && git pull") end |
.update_configure_file ⇒ Object
75 76 77 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb', line 75 def self.update_configure_file Fastlane::Helper::ConfigureHelper.update_configure_file_from_repository end |