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 (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 "repos/#{Repository.new(repo)}/comments/#{id}", options
end

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

List comments for a single commit

Parameters:

  • repo (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 = {})
  get "repos/#{Repository.new(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

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

Parameters:

  • repo (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:



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

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

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

Delete a commit comment

Parameters:

  • repo (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, "repos/#{Repository.new(repo)}/comments/#{id}", options
end

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

List all commit comments

Parameters:

  • repo (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 = {})
  get "repos/#{Repository.new(repo)}/comments", options
end

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

Update a commit comment

Examples:

Update a commit comment

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

Parameters:

  • repo (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 "repos/#{Repository.new(repo)}/comments/#{id}", options.merge(params)
end