Sha256: 3ff78640d10c02538f78f0e97cbd63ba1f729056d9881709b612b118690c949f

Contents?: true

Size: 1.96 KB

Versions: 124

Compression:

Stored size: 1.96 KB

Contents

module Fastlane
  module Actions
    class NumberOfCommitsAction < Action
      def self.is_git?
        Actions.sh 'git rev-parse HEAD'
        return true
      rescue
        return false
      end

      def self.run(params)
        if is_git?
          if params[:all]
            command = 'git rev-list --all --count'
          else
            command = 'git rev-list HEAD --count'
          end
        else
          UI.user_error!("Not in a git repository.")
        end
        return Actions.sh(command).strip.to_i
      end

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

      def self.description
        "Return the number of commits in current git branch"
      end

      def self.return_value
        "The total number of all commits in current git branch"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :all,
                                       env_name: "FL_NUMBER_OF_COMMITS_ALL",
                                       optional: true,
                                       is_string: false,
                                       description: "Returns number of all commits instead of current branch")
        ]
      end

      def self.details
        "You can use this action to get the number of commits of this branch. This is useful if you want to set the build number to the number of commits. See `faslane actions number_of_commits` for more details"
      end

      def self.authors
        ["onevcat", "samuelbeek"]
      end

      def self.is_supported?(platform)
        true
      end

      def self.example_code
        [
          'increment_build_number(build_number: number_of_commits)',
          'build_number = number_of_commits(all: true)
          increment_build_number(build_number: number_of_commits)'
        ]
      end

      def self.category
        :source_control
      end
    end
  end
end

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
fastlane-2.37.0.beta.20170602010027 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.37.0.beta.20170601010043 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170531010050 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170530010040 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170529010025 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170528010028 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170527010029 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.35.1 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170526010038 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.36.0.beta.20170525010052 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.35.0 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.34.0 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.34.0.beta.20170524010028 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.33.0 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.33.0.beta.20170523010027 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.33.0.beta.20170522010027 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.33.0.beta.20170521010032 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.33.0.beta.20170520010019 fastlane/lib/fastlane/actions/number_of_commits.rb
fastlane-2.32.1 fastlane/lib/fastlane/actions/number_of_commits.rb