Sha256: 6091698eb8dc591d05801bb52f60cda4c2b64d8282ac64f5399bb618cb1ef3ce

Contents?: true

Size: 1.53 KB

Versions: 36

Compression:

Stored size: 1.53 KB

Contents

module Fastlane
  module Actions
    module SharedValues
      GIT_BRANCH_ENV_VARS = %w(GIT_BRANCH BRANCH_NAME TRAVIS_BRANCH BITRISE_GIT_BRANCH CI_BUILD_REF_NAME CI_COMMIT_REF_NAME WERCKER_GIT_BRANCH BUILDKITE_BRANCH APPCENTER_BRANCH CIRCLE_BRANCH).reject do |branch|
        # Removing because tests break on CircleCI
        Helper.test? && branch == "CIRCLE_BRANCH"
      end.freeze
    end

    class GitBranchAction < Action
      def self.run(params)
        env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| FastlaneCore::Env.truthy?(env_var) }
        ENV.fetch(env_name.to_s) { `git symbolic-ref HEAD --short 2>/dev/null`.strip }
      end

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

      def self.description
        "Returns the name of the current git branch, possibly as managed by CI ENV vars"
      end

      def self.details
        "If no branch could be found, this action will return an empty string"
      end

      def self.available_options
        []
      end

      def self.output
        [
          ['GIT_BRANCH_ENV_VARS', 'The git branch environment variables']
        ]
      end

      def self.authors
        ["KrauseFx"]
      end

      def self.is_supported?(platform)
        true
      end

      def self.example_code
        [
          'git_branch'
        ]
      end

      def self.return_type
        :string
      end

      def self.category
        :source_control
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
fastlane-2.178.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.177.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.176.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.175.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.174.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.173.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.172.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.171.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.170.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.169.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.168.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.167.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.166.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.165.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.164.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.163.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.162.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.161.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.160.0 fastlane/lib/fastlane/actions/git_branch.rb
fastlane-2.159.0 fastlane/lib/fastlane/actions/git_branch.rb