Sha256: e40a2d06c1e57981fe3f231575ce8d95cd40209382c1710225e50cc59251d779

Contents?: true

Size: 1.51 KB

Versions: 35

Compression:

Stored size: 1.51 KB

Contents

module Fastlane
  module Actions
    module SharedValues
    end

    # Raises an exception and stop the lane execution if the repo is not on a specific branch
    class EnsureGitBranchAction < Action
      def self.run(params)
        branch = params[:branch]
        branch_expr = /#{branch}/
        if Actions.git_branch =~ branch_expr
          UI.success("Git branch match `#{branch}`, all good! 💪")
        else
          UI.user_error!("Git is not on a branch matching `#{branch}`. Current branch is `#{Actions.git_branch}`! Please ensure the repo is checked out to the correct branch.")
        end
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Raises an exception if not on a specific git branch"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :branch,
                                       env_name: "FL_ENSURE_GIT_BRANCH_NAME",
                                       description: "The branch that should be checked for. String that can be either the full name of the branch or a regex to match",
                                       is_string: true,
                                       default_value: 'master')
        ]
      end

      def self.output
        []
      end

      def self.author
        ['dbachrach', 'Liquidsoul']
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
fastlane-1.104.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.103.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.102.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.101.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.100.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.99.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.98.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.97.2 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.97.1 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.97.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.96.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.95.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.94.1 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.94.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.93.1 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.93.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.92.0 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.92.0.beta2 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.92.0.beta1 lib/fastlane/actions/ensure_git_branch.rb
fastlane-1.91.0 lib/fastlane/actions/ensure_git_branch.rb