Module: Octokit::Client::CommitComments

Included in:
Octokit::Client
Defined in:
lib/octokit/client/commit_comments.rb

Overview

Methods for the Commit Comments API

Instance Method Summary collapse

Instance Method Details

#commit_comment(repo, id, options = {}) ⇒ Sawyer::Resource

Get a single commit comment


34
35
36
# File 'lib/octokit/client/commit_comments.rb', line 34

def commit_comment(repo, id, options = {})
  get "#{Repository.path repo}/comments/#{id}", options
end

#commit_comments(repo, sha, options = {}) ⇒ Array

List comments for a single commit


24
25
26
# File 'lib/octokit/client/commit_comments.rb', line 24

def commit_comments(repo, sha, options = {})
  get "#{Repository.path repo}/commits/#{sha}/comments", options
end

#create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {}) ⇒ Sawyer::Resource

Create a commit comment

Examples:

Create a commit comment

comment = Octokit.create_commit_comment("octocat/Hello-World", "827efc6d56897b048c772eb4087f854f46256132", "My comment message", "README.md", 10, 1)
comment.commit_id # => "827efc6d56897b048c772eb4087f854f46256132"
comment.id # => 54321
comment.body # => "My comment message"
comment.path # => "README.md"
comment.line # => 10
comment.position # => 1

See Also:


56
57
58
59
60
61
62
63
64
# File 'lib/octokit/client/commit_comments.rb', line 56

def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, options = {})
  params = {
    :body => body,
    :path => path,
    :line => line,
    :position => position
  }
  post "#{Repository.path repo}/commits/#{sha}/comments", options.merge(params)
end

#delete_commit_comment(repo, id, options = {}) ⇒ Boolean

Delete a commit comment


90
91
92
# File 'lib/octokit/client/commit_comments.rb', line 90

def delete_commit_comment(repo, id, options = {})
  boolean_from_response :delete, "#{Repository.path repo}/comments/#{id}", options
end

#list_commit_comments(repo, options = {}) ⇒ Array

List all commit comments


14
15
16
# File 'lib/octokit/client/commit_comments.rb', line 14

def list_commit_comments(repo, options = {})
  get "#{Repository.path repo}/comments", options
end

#update_commit_comment(repo, id, body, options = {}) ⇒ Sawyer::Resource

Update a commit comment

Examples:

Update a commit comment

comment = Octokit.update_commit_comment("octocat/Hello-World", "860296", "Updated commit comment")
comment.id # => 860296
comment.body # => "Updated commit comment"

See Also:


77
78
79
80
81
82
# File 'lib/octokit/client/commit_comments.rb', line 77

def update_commit_comment(repo, id, body, options = {})
  params = {
    :body => body
  }
  patch "#{Repository.path repo}/comments/#{id}", options.merge(params)
end