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

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (String)

    The ID of the comment to fetch

Returns:

  • (Sawyer::Resource)

    Commit comment

See Also:



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

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • sha (String)

    The SHA of the commit whose comments will be fetched

Returns:

  • (Array)

    List of commit comments

See Also:



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

def commit_comments(repo, sha, options = {})
  paginate "#{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

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • sha (String)

    Sha of the commit to comment on

  • body (String)

    Message

  • path (String) (defaults to: nil)

    Relative path of file to comment on

  • line (Integer) (defaults to: nil)

    Line number in the file to comment on

  • position (Integer) (defaults to: nil)

    Line index in the diff to comment on

Returns:

  • (Sawyer::Resource)

    Commit comment

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

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (String)

    The ID of the comment to delete

Returns:

  • (Boolean)

    Success

See Also:



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

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

Returns:

  • (Array)

    List of commit comments

See Also:



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

def list_commit_comments(repo, options = {})
  paginate "#{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"

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (String)

    The ID of the comment to update

  • body (String)

    Message

Returns:

  • (Sawyer::Resource)

    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