module Octokit::Client::Commits

def commit(repo, sha, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/commits/#get-a-single-commit -

Returns:
  • (Sawyer::Resource) - A hash representing the commit

Parameters:
  • sha (String) -- The SHA of the commit to fetch
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def commit(repo, sha, options = {})
  get "#{Repository.path repo}/commits/#{sha}", options
end

def commits(*args)

Other tags:
    See: https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository -

Returns:
  • (Array) - An array of hashes representing commits

Parameters:
  • options (String) -- :sha Commit SHA or branch name from which to start the list
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
  • options (String) -- :sha Commit SHA or branch name from which to start the list
  • sha_or_branch (String) -- A commit SHA or branch name
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Overloads:
  • commits(repo, options = {})
  • commits(repo, sha_or_branch, options = {})

Deprecated:
def commits(*args)
  arguments = Octokit::RepoArguments.new(args)
  sha_or_branch = arguments.pop
  arguments.options[:sha] = sha_or_branch if sha_or_branch
  paginate "#{Repository.new(arguments.repo).path}/commits", arguments.options
end

def commits_before(*args)

Other tags:
    See: https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository -

Returns:
  • (Array) - An array of hashes representing commits

Parameters:
  • sha_or_branch (String) -- Commit SHA or branch name from which to start the list
  • date (String) -- Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
  • date (String) -- Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Deprecated:

Overloads:
  • commits_before(repo, date, sha_or_branch, options = {})
  • commits_before(repo, date, options = {})
def commits_before(*args)
  arguments = Octokit::RepoArguments.new(args)
  date = parse_date(arguments.shift)
  params = arguments.options
  params.merge!(until: iso8601(date))
  sha_or_branch = arguments.pop
  params[:sha] = sha_or_branch if sha_or_branch
  commits(arguments.repo, params)
end

def commits_between(*args)

Other tags:
    See: https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository -

Returns:
  • (Array) - An array of hashes representing commits

Parameters:
  • sha_or_branch (String) -- Commit SHA or branch name from which to start the list
  • end_date (String) -- End Date on which we want to compare
  • start_date (String) -- Start Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
  • end_date (String) -- End Date on which we want to compare
  • start_date (String) -- Start Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Deprecated:

Overloads:
  • commits_between(repo, start_date, end_date, sha_or_branch, options = {})
  • commits_between(repo, start_date, end_date, options = {})
def commits_between(*args)
  arguments = Octokit::RepoArguments.new(args)
  date = parse_date(arguments.shift)
  end_date = parse_date(arguments.shift)
  if date > end_date
    raise ArgumentError, "Start date #{date} does not precede #{end_date}"
  end
  params = arguments.options
  params.merge!(since: iso8601(date), until: iso8601(end_date))
  sha_or_branch = arguments.pop
  params[:sha] = sha_or_branch if sha_or_branch
  commits(arguments.repo, params)
end

def commits_on(*args)

Other tags:
    See: https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository -

Returns:
  • (Array) - An array of hashes representing commits

Parameters:
  • sha_or_branch (String) -- Commit SHA or branch name from which to start the list
  • date (String) -- Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
  • date (String) -- Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Deprecated:

Overloads:
  • commits_on(repo, date, sha_or_branch, options = {})
  • commits_on(repo, date, options = {})
def commits_on(*args)
  arguments = Octokit::RepoArguments.new(args)
  date = parse_date(arguments.shift)
  params = arguments.options
  end_date = date + 1
  params.merge!(since: iso8601(date), until: iso8601(end_date))
  sha_or_branch = arguments.pop
  params[:sha] = sha_or_branch if sha_or_branch
  commits(arguments.repo, params)
end

def commits_since(*args)

Other tags:
    See: https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository -

Returns:
  • (Array) - An array of hashes representing commits

Parameters:
  • options (String) -- :sha Commit SHA or branch name from which to start the list
  • sha_or_branch (String) -- A commit SHA or branch name
  • date (String) -- Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
  • options (String) -- :sha Commit SHA or branch name from which to start the list
  • date (String) -- Date on which we want to compare
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Deprecated:

Overloads:
  • commits_since(repo, date, sha_or_branch, options = {})
  • commits_since(repo, date, options = {})
def commits_since(*args)
  arguments = Octokit::RepoArguments.new(args)
  date = parse_date(arguments.shift)
  params = arguments.options
  params.merge!(since: iso8601(date))
  sha_or_branch = arguments.pop
  params[:sha] = sha_or_branch if sha_or_branch
  commits(arguments.repo, params)
end

def compare(repo, start, endd, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/commits/#compare-two-commits -

Returns:
  • (Sawyer::Resource) - A hash representing the comparison

Parameters:
  • endd (String) -- The sha of the ending commit
  • start (String) -- The sha of the starting commit
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def compare(repo, start, endd, options = {})
  paginate "#{Repository.path repo}/compare/#{start}...#{endd}", options do |data, last_response|
    data.commits.concat last_response.data.commits
  end
end

def create_commit(repo, message, tree, parents = nil, options = {})

Other tags:
    Example: Create a commit -

Other tags:
    See: https://developer.github.com/v3/git/commits/#create-a-commit -

Returns:
  • (Sawyer::Resource) - A hash representing the new commit

Parameters:
  • parents (String, Array) -- One SHA (for a normal commit) or an array of SHAs (for a merge) of the new commit's parent commits. If ommitted or empty, a root commit will be created
  • tree (String) -- The SHA of the tree object the new commit will point to
  • message (String) -- The commit message
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def create_commit(repo, message, tree, parents = nil, options = {})
  params = { message: message, tree: tree }
  params[:parents] = [parents].flatten if parents
  post "#{Repository.path repo}/git/commits", options.merge(params)
end

def git_commit(repo, sha, options = {})

Other tags:
    See: https://developer.github.com/v3/git/commits/#get-a-commit -

Returns:
  • (Sawyer::Resource) - A hash representing the commit

Parameters:
  • sha (String) -- The SHA of the commit to fetch
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def git_commit(repo, sha, options = {})
  get "#{Repository.path repo}/git/commits/#{sha}", options
end

def iso8601(date)

def iso8601(date)
  if date.respond_to?(:iso8601)
    date.iso8601
  else
    date.strftime('%Y-%m-%dT%H:%M:%S%Z')
  end
end

def merge(repo, base, head, options = {})

Other tags:
    See: https://developer.github.com/v3/repos/merging/#perform-a-merge -

Returns:
  • (Sawyer::Resource) - A hash representing the comparison

Options Hash: (**options)
  • :commit_message (String) -- The commit message for the merge

Parameters:
  • head (String) -- The branch or SHA1 to merge
  • base (String) -- The name of the base branch to merge into
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def merge(repo, base, head, options = {})
  params = {
    base: base,
    head: head
  }.merge(options)
  post "#{Repository.path repo}/merges", params
end

def parse_date(date)

Returns:
  • (DateTime) -

Parameters:
  • date (String) -- String representation of a date
def parse_date(date)
  date = DateTime.parse(date.to_s)
rescue ArgumentError
  raise ArgumentError, "#{date} is not a valid date"
end