diff --git a/lib/fastlane/plugin/revenuecat_internal/actions/create_next_snapshot_version_action.rb b/lib/fastlane/plugin/revenuecat_internal/actions/create_next_snapshot_version_action.rb index aa39a42..6cd4eb0 100644 --- a/lib/fastlane/plugin/revenuecat_internal/actions/create_next_snapshot_version_action.rb +++ b/lib/fastlane/plugin/revenuecat_internal/actions/create_next_snapshot_version_action.rb @@ -11,12 +11,11 @@ def self.run(params) github_pr_token = params[:github_pr_token] files_to_update = params[:files_to_update] files_to_update_without_prerelease_modifiers = params[:files_to_update_without_prerelease_modifiers] - branch = params[:branch] next_version_snapshot = Helper::RevenuecatInternalHelper.calculate_next_snapshot_version(previous_version_number) new_branch_name = "bump/#{next_version_snapshot}" - Helper::RevenuecatInternalHelper.validate_local_config_status_for_bump(branch, new_branch_name, github_pr_token) + Helper::RevenuecatInternalHelper.validate_local_config_status_for_bump(nil, new_branch_name, github_pr_token) Helper::RevenuecatInternalHelper.create_new_branch_and_checkout(new_branch_name) @@ -64,12 +63,7 @@ def self.available_options description: "Files that contain the version number without release modifiers and need to have it updated", optional: true, default_value: [], - type: Array), - FastlaneCore::ConfigItem.new(key: :branch, - description: "Allows to execute the action from the given branch", - optional: true, - default_value: "main", - type: String) + type: Array) ] end diff --git a/lib/fastlane/plugin/revenuecat_internal/helper/revenuecat_internal_helper.rb b/lib/fastlane/plugin/revenuecat_internal/helper/revenuecat_internal_helper.rb index fe02e6c..fc8ec07 100644 --- a/lib/fastlane/plugin/revenuecat_internal/helper/revenuecat_internal_helper.rb +++ b/lib/fastlane/plugin/revenuecat_internal/helper/revenuecat_internal_helper.rb @@ -145,7 +145,7 @@ def self.create_pr_to_main(title, body, repo_name, github_pr_token) ) end - def self.validate_local_config_status_for_bump(branch, new_branch, github_pr_token) + def self.validate_local_config_status_for_bump(current_branch, new_branch, github_pr_token) # Ensure GitHub API token is set if github_pr_token.nil? || github_pr_token.empty? UI.error("A github_pr_token parameter or an environment variable GITHUB_PULL_REQUEST_API_TOKEN is required to create a pull request") @@ -153,7 +153,7 @@ def self.validate_local_config_status_for_bump(branch, new_branch, github_pr_tok UI.user_error!("Could not find value for GITHUB_PULL_REQUEST_API_TOKEN") end ensure_new_branch_local_remote(new_branch) - Actions::EnsureGitBranchAction.run(branch: branch) + Actions::EnsureGitBranchAction.run(branch: current_branch) unless current_branch.nil? Actions::EnsureGitStatusCleanAction.run({}) end diff --git a/spec/actions/create_next_snapshot_version_action_spec.rb b/spec/actions/create_next_snapshot_version_action_spec.rb index 3204c1a..7659b49 100644 --- a/spec/actions/create_next_snapshot_version_action_spec.rb +++ b/spec/actions/create_next_snapshot_version_action_spec.rb @@ -2,13 +2,12 @@ describe '#run' do let(:github_pr_token) { 'fake-github-pr-token' } let(:repo_name) { 'fake-repo-name' } - let(:branch) { 'branch' } let(:current_version) { '1.12.0' } let(:next_version) { '1.13.0-SNAPSHOT' } it 'calls all the appropriate methods with appropriate parameters' do expect(Fastlane::Helper::RevenuecatInternalHelper).to receive(:validate_local_config_status_for_bump) - .with(branch, "bump/#{next_version}", github_pr_token) + .with(nil, "bump/#{next_version}", github_pr_token) .once expect(Fastlane::Helper::RevenuecatInternalHelper).to receive(:calculate_next_snapshot_version) .with(current_version) @@ -31,15 +30,14 @@ repo_name: repo_name, github_pr_token: github_pr_token, files_to_update: ['./test_file.sh', './test_file2.rb'], - files_to_update_without_prerelease_modifiers: ['./test_file4.swift', './test_file5.kt'], - branch: branch + files_to_update_without_prerelease_modifiers: ['./test_file4.swift', './test_file5.kt'] ) end end describe '#available_options' do it 'has correct number of options' do - expect(Fastlane::Actions::CreateNextSnapshotVersionAction.available_options.size).to eq(6) + expect(Fastlane::Actions::CreateNextSnapshotVersionAction.available_options.size).to eq(5) end end end diff --git a/spec/helper/revenuecat_internal_helper_spec.rb b/spec/helper/revenuecat_internal_helper_spec.rb index b4de821..1b6b183 100644 --- a/spec/helper/revenuecat_internal_helper_spec.rb +++ b/spec/helper/revenuecat_internal_helper_spec.rb @@ -413,6 +413,11 @@ def setup_stubs Fastlane::Helper::RevenuecatInternalHelper.validate_local_config_status_for_bump('fake-branch', 'new-branch', 'fake-github-pr-token') end + it 'does not check repo is in specific branch if none passed' do + expect(Fastlane::Actions::EnsureGitBranchAction).not_to receive(:run) + Fastlane::Helper::RevenuecatInternalHelper.validate_local_config_status_for_bump(nil, 'new-branch', 'fake-github-pr-token') + end + it 'ensures repo is in a clean state' do expect(Fastlane::Actions::EnsureGitStatusCleanAction).to receive(:run).with({}).once Fastlane::Helper::RevenuecatInternalHelper.validate_local_config_status_for_bump('fake-branch', 'new-branch', 'fake-github-pr-token')