Module: Octokit::Client::Commits
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Included In: | |
| Defined in: | lib/octokit/client/commits.rb | 
Overview
Methods for the Commits API
Instance Method Summary
- 
    
      #commit(repo, sha, options = {})  ⇒ Sawyer::Resource 
    
    Get a single commit. 
- 
    
      #commits(repo, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
      (also: #list_commits)
    
    List commits. 
- 
    
      #commits_before(repo, date, options = {})  ⇒ Array<Sawyer::Resource> 
    
    Get commits before a specified date. 
- 
    
      #commits_between(repo, start_date, end_date, options = {})  ⇒ Array<Sawyer::Resource> 
    
    Get commits made between two nominated dates. 
- 
    
      #commits_on(repo, date, options = {})  ⇒ Array<Sawyer::Resource> 
    
    Get commits on a specified date. 
- 
    
      #commits_since(repo, date, options = {})  ⇒ Array<Sawyer::Resource> 
    
    Get commits after a specified date. 
- 
    
      #compare(repo, start, endd, options = {})  ⇒ Sawyer::Resource 
    
    Compare two commits. 
- 
    
      #create_commit(repo, message, tree, parents = nil, options = {})  ⇒ Sawyer::Resource 
    
    Create a commit. 
- 
    
      #git_commit(repo, sha, options = {})  ⇒ Sawyer::Resource 
    
    Get a detailed git commit. 
- 
    
      #list_commits(*args)  
    
    Alias for #commits. 
- 
    
      #merge(repo, base, head, options = {})  ⇒ Sawyer::Resource 
    
    Merge a branch or sha. 
Instance Method Details
    #commit(repo, sha, options = {})  ⇒ Sawyer::Resource 
  
Get a single commit
# File 'lib/octokit/client/commits.rb', line 143
def commit(repo, sha, = {}) get "#{Repository.path repo}/commits/#{sha}", end
    
      #commits(repo, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
      #commits(repo, options = {})  ⇒ Array<Sawyer::Resource> 
    
    Also known as: #list_commits
  
Array<Sawyer::Resource> 
      #commits(repo, options = {})  ⇒ Array<Sawyer::Resource> 
    List commits
# File 'lib/octokit/client/commits.rb', line 23
def commits(*args) arguments = Octokit::RepoArguments.new(args) sha_or_branch = arguments.pop arguments.[:sha] = sha_or_branch if sha_or_branch paginate "#{Repository.new(arguments.repo).path}/commits", arguments. end
    
      #commits_before(repo, date, options = {})  ⇒ Array<Sawyer::Resource> 
      #commits_before(repo, date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    
  
Array<Sawyer::Resource> 
      #commits_before(repo, date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    Get commits before a specified date
# File 'lib/octokit/client/commits.rb', line 71
def commits_before(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) params = arguments. params.merge!(until: iso8601(date)) sha_or_branch = arguments.pop params[:sha] = sha_or_branch if sha_or_branch commits(arguments.repo, params) end
    
      #commits_between(repo, start_date, end_date, options = {})  ⇒ Array<Sawyer::Resource> 
      #commits_between(repo, start_date, end_date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    
  
Array<Sawyer::Resource> 
      #commits_between(repo, start_date, end_date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    Get commits made between two nominated dates
# File 'lib/octokit/client/commits.rb', line 122
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. 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
    
      #commits_on(repo, date, options = {})  ⇒ Array<Sawyer::Resource> 
      #commits_on(repo, date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    
  
Array<Sawyer::Resource> 
      #commits_on(repo, date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    Get commits on a specified date
# File 'lib/octokit/client/commits.rb', line 95
def commits_on(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) params = arguments. 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
    
      #commits_since(repo, date, options = {})  ⇒ Array<Sawyer::Resource> 
      #commits_since(repo, date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    
  
Array<Sawyer::Resource> 
      #commits_since(repo, date, sha_or_branch, options = {})  ⇒ Array<Sawyer::Resource> 
    Get commits after a specified date
# File 'lib/octokit/client/commits.rb', line 47
def commits_since(*args) arguments = Octokit::RepoArguments.new(args) date = parse_date(arguments.shift) params = arguments. params.merge!(since: iso8601(date)) sha_or_branch = arguments.pop params[:sha] = sha_or_branch if sha_or_branch commits(arguments.repo, params) end
    #compare(repo, start, endd, options = {})  ⇒ Sawyer::Resource 
  
Compare two commits
When using auto_pagination, commits from all pages will be concatenated into the commits attribute of the first page's response.
# File 'lib/octokit/client/commits.rb', line 192
def compare(repo, start, endd, = {}) paginate "#{Repository.path repo}/compare/#{start}...#{endd}", do |data, last_response| data.commits.concat last_response.data.commits end end
    #create_commit(repo, message, tree, parents = nil, options = {})  ⇒ Sawyer::Resource 
  
Create a commit
Optionally pass author and committer hashes in options if you'd like manual control over those parameters. If absent, details will be inferred from the authenticated user. See GitHub's documentation for details about how to format committer identities.
# File 'lib/octokit/client/commits.rb', line 176
def create_commit(repo, , tree, parents = nil, = {}) params = { message: , tree: tree } params[:parents] = [parents].flatten if parents post "#{Repository.path repo}/git/commits", .merge(params) end
    #git_commit(repo, sha, options = {})  ⇒ Sawyer::Resource 
  
Get a detailed git commit
# File 'lib/octokit/client/commits.rb', line 153
def git_commit(repo, sha, = {}) get "#{Repository.path repo}/git/commits/#{sha}", end
#list_commits(*args)
Alias for #commits.
# File 'lib/octokit/client/commits.rb', line 29
alias list_commits commits
    #merge(repo, base, head, options = {})  ⇒ Sawyer::Resource 
  
Merge a branch or sha
# File 'lib/octokit/client/commits.rb', line 206
def merge(repo, base, head, = {}) params = { base: base, head: head }.merge() post "#{Repository.path repo}/merges", params end