Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace two GitHelper methods with Fastlane actions #531

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ _None_

### Internal Changes

_None_
- Added a deprecation notice to the `GitHelper.ensure_on_branch!` method [#531]
- Added a deprecation notice to the `GitHelper.update_submodules` method [#531]

## 9.4.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def self.run(params)

UI.user_error!("Can't build beta and final at the same time!") if params[:final] && params[:beta]

Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci
# Verify that the current branch is a release branch. Notice that `ensure_git_branch` expects a RegEx parameter
ensure_git_branch(branch: '^release/') unless other_action.is_ci

has_alpha_version = params[:has_alpha_version]
project_root_folder = params[:project_root_folder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def self.run(params)
require_relative '../../helper/android/android_git_helper'
require_relative '../../helper/android/android_version_helper'

Fastlane::Helper::GitHelper.ensure_on_branch!('release')
# Verify that the current branch is a release branch. Notice that `ensure_git_branch` expects a RegEx parameter
ensure_git_branch(branch: '^release/')

has_alpha_version = params[:has_alpha_version]
project_root_folder = params[:project_root_folder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def self.run(params)
require_relative '../../helper/android/android_git_helper'
require_relative '../../helper/android/android_version_helper'

Fastlane::Helper::GitHelper.ensure_on_branch!('release')
# Verify that the current branch is a release branch. Notice that `ensure_git_branch` expects a RegEx parameter
ensure_git_branch(branch: '^release/')

has_alpha_version = params[:has_alpha_version]
project_root_folder = params[:project_root_folder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def self.run(params)

# Update submodules then lint translations
unless params[:lint_task].nil? || params[:lint_task].empty?
Fastlane::Helper::GitHelper.update_submodules
git_submodule_update(
recursive: true,
init: true
)
Action.sh('./gradlew', params[:lint_task])
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def self.run(params)
require_relative '../../helper/ios/ios_git_helper'
require_relative '../../helper/ios/ios_version_helper'

Fastlane::Helper::GitHelper.ensure_on_branch!('release')
# Verify that the current branch is a release branch. Notice that `ensure_git_branch` expects a RegEx parameter
ensure_git_branch(branch: '^release/')
create_config
show_config

Expand Down
10 changes: 10 additions & 0 deletions lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def self.checkout_and_pull(branch)

# Update every submodule in the current git repository
#
# @deprecated This method is going to be removed soon. Fastlane has a built-in `git_submodule_update` action that can be used instead.
#
def self.update_submodules
UI.deprecated("The `update_submodules` method will soon be removed from `release-toolkit`. Please use fastlane's `git_submodule_update` action instead.")
Action.sh('git', 'submodule', 'update', '--init', '--recursive')
end

Expand Down Expand Up @@ -209,7 +212,14 @@ def self.branch_exists?(branch_name)
#
# @raise [UserError] Raises a user_error! and interrupts the lane if we are not on the expected branch.
#
# @deprecated This method is going to be removed soon. Fastlane has a built-in `ensure_git_branch` action that can be used instead.
# After updating to Fastlane version `2.217.0` or later, the `FL_GIT_BRANCH_DONT_USE_ENV_VARS` environment
# variable can be set to `true` to disable the use of environment variables for the `git_branch` action that
# `ensure_git_branch` relies on. This will make `ensure_git_branch` work as expected in CI environments.
# See https://github.com/fastlane/fastlane/pull/21597 for more details.
#
def self.ensure_on_branch!(branch_name)
UI.deprecated("The `ensure_on_branch!` method will soon be removed from `release-toolkit`. Please use fastlane's `ensure_git_branch` action (+ potentially set `FL_GIT_BRANCH_DONT_USE_ENV_VARS=true`) instead.")
current_branch_name = Action.sh('git', 'symbolic-ref', '-q', 'HEAD')
UI.user_error!("This command works only on #{branch_name} branch") unless current_branch_name.include?(branch_name)
end
Expand Down