class Pantograph::Actions::NumberOfCommitsAction

Public Class Methods

authors() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 54
def self.authors
  ['onevcat', 'samuelbeek', 'johnknapprs']
end
available_options() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 32
def self.available_options
  [
    PantographCore::ConfigItem.new(
      key: :all,
      env_name: 'NUMBER_OF_COMMITS_ALL',
      optional: true,
      is_string: false,
      description: 'Returns number of all commits instead of current branch'
    )
  ]
end
category() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 74
def self.category
  :source_control
end
description() click to toggle source

@!group Documentation

# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 21
def self.description
  'Return the number of commits in current git branch'
end
details() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 25
def self.details
end
example_code() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 62
def self.example_code
  [
    '
    ENV["VERSION_NAME"] = number_of_commits
    ',
    '
    build_number = number_of_commits(all: true)
    puts build_number
    '
  ]
end
is_supported?(platform) click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 58
def self.is_supported?(platform)
  true
end
output() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 48
def self.output
  [
    ['NUMBER_OF_COMMITS', 'Total number of git commits']
  ]
end
return_type() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 28
def self.return_type
  :int
end
return_value() click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 44
def self.return_value
  'The total number of all commits in current git branch'
end
run(params) click to toggle source
# File pantograph/lib/pantograph/actions/number_of_commits.rb, line 8
def self.run(params)
  Pantograph::Helper::Git.is_git?

  type    = params[:all] ? '--all' : 'HEAD'
  commits = Actions.sh("git rev-list #{type} --count").strip.to_i

  Actions.lane_context[:NUMBER_OF_COMMITS] = commits
end