From a45f2a686b789ab058fa498225b6ddaa2abfff14 Mon Sep 17 00:00:00 2001 From: Spencer Transier <17955542+spencertransier@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:02:36 -0800 Subject: [PATCH 1/3] Add checkout and pull wrapper --- .../actions/common/checkout_and_pull.rb | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/common/checkout_and_pull.rb diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/checkout_and_pull.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/checkout_and_pull.rb new file mode 100644 index 000000000..fda0b2e8b --- /dev/null +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/checkout_and_pull.rb @@ -0,0 +1,39 @@ +require 'fastlane/action' +require_relative '../../helper/git_helper' +module Fastlane + module Actions + class CheckoutAndPullAction < Action + def self.run(params) + branch_name = params[:branch_name] + + Fastlane::Helper::GitHelper.checkout_and_pull(branch_name) + end + + def self.description + 'Checkout and pull the specified branch' + end + + def self.return_value + 'True if it succeeded switching and pulling, false if there was an error during the switch or pull.' + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :branch_name, + env_name: 'BRANCH_NAME_TO_CHECKOUT_AND_PULL', + description: 'The name of the branch to checkout and pull', + optional: false, + type: String), + ] + end + + def self.is_supported?(platform) + true + end + + def self.authors + ['Automattic'] + end + end + end +end From 55cc9c58628fb499b23aec52e5e16c7a2c69f7d4 Mon Sep 17 00:00:00 2001 From: Spencer Transier <17955542+spencertransier@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:02:42 -0800 Subject: [PATCH 2/3] Add create branch action --- .../actions/common/create_branch.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_branch.rb diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_branch.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_branch.rb new file mode 100644 index 000000000..efc3e4c26 --- /dev/null +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_branch.rb @@ -0,0 +1,45 @@ +require 'fastlane/action' +require_relative '../../helper/git_helper' +module Fastlane + module Actions + class CreateBranchAction < Action + def self.run(params) + branch_name = params[:branch_name] + from = params[:from] + + Fastlane::Helper::GitHelper.create_branch(branch_name, from: from) + end + + def self.description + 'Create a new branch named `branch_name`, cutting it from branch/commit/tag `from`' + end + + def self.details + 'If the branch with that name already exists, it will instead switch to it and pull new commits.' + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :branch_name, + env_name: 'BRANCH_NAME_TO_CREATE', + description: 'The full name of the new branch to create, e.g. "release/1.2"', + optional: false, + type: String), + FastlaneCore::ConfigItem.new(key: :from, + env_name: 'BRANCH_OR_COMMIT_TO_CUT_FROM', + description: 'The branch/tag/commit from which to cut the branch from. If `nil`, will cut the new branch from the current commit. Otherwise, will checkout that commit/branch/tag before cutting the branch.', + optional: true, + type: String), + ] + end + + def self.is_supported?(platform) + true + end + + def self.authors + ['Automattic'] + end + end + end +end From ea3f74620e544b6f20b256fecb8f4719f3f42422 Mon Sep 17 00:00:00 2001 From: Spencer Transier <17955542+spencertransier@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:06:14 -0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b49eca542..ae5b38852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ _None_ ### New Features - Added optional `build_gradle_path` and `version_properties_path` config items to actions that previously used the `PROJECT_ROOT_FOLDER` environment variable [#519] +- Added a `checkout_and_pull` git action [#532] +- Added a `create_branch` git action [#532] ### Internal Changes