class Github::Repos::Comments

Constants

REQUIRED_COMMENT_OPTIONS
VALID_COMMENT_OPTIONS

Public Instance Methods

all(*args)
Alias for: list
create(*args) click to toggle source

Creates a commit comment

Inputs

  • :body - Required string.

  • :comment_id - Required string - Sha of the commit to comment on.

  • :line - Required number - Line number in the file to comment on.

  • :path - Required string - Relative path of the file to comment on.

  • :position - Required number - Line index in the diff to comment on.

Examples

github = Github.new
github.repos.comments.create 'user-name', 'repo-name', 'sha-key', 
  "body" => "Nice change",
  "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "line" => 1,
  "path" =>  "file1.txt",
  "position" =>  4
# File lib/github_api/repos/comments.rb, line 73
def create(*args)
  arguments(args, :required => [:user, :repo, :sha]) do
    sift VALID_COMMENT_OPTIONS
    assert_required REQUIRED_COMMENT_OPTIONS
  end
  params = arguments.params

  post_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
end
delete(*args) click to toggle source

Deletes a commit comment

Examples

github = Github.new
github.repos.comments.delete 'user-name', 'repo-name', 'comment-id'
# File lib/github_api/repos/comments.rb, line 108
def delete(*args)
  arguments(args, :required => [:user, :repo, :comment_id])
  params = arguments.params

  delete_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
end
find(*args)
Alias for: get
get(*args) click to toggle source

Gets a single commit comment

Examples

github = Github.new
github.repos.comments.get 'user-name', 'repo-name', 'comment-id'
# File lib/github_api/repos/comments.rb, line 47
def get(*args)
  arguments(args, :required => [:user, :repo, :comment_id])
  params = arguments.params

  get_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
end
Also aliased as: find
list(*args) { |el| ... } click to toggle source

List commit comments for a repository

Examples

github = Github.new
github.repos.comments.list 'user-name', 'repo-name'
github.repos.comments.list 'user-name', 'repo-name' { |com| ... }

List comments for a single commit

Examples

github.repos.comments.list 'user-name', 'repo-name',
 :sha => '6dcb09b5b57875f334f61aebed695e2e4193db5e'
# File lib/github_api/repos/comments.rb, line 27
def list(*args)
  arguments(args, :required => [:user, :repo])
  params = arguments.params

  response = if (sha = params.delete('sha'))
    get_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
  else
    get_request("/repos/#{user}/#{repo}/comments", params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
update(*args) click to toggle source

Update a commit comment

Inputs

  • :body - Required string.

Examples

github = Github.new
github.repos.comments.update 'user-name', 'repo-name',
  'comment-id', "body" => "Nice change"
# File lib/github_api/repos/comments.rb, line 93
def update(*args)
  arguments(args, :required => [:user, :repo, :comment_id]) do
    assert_required REQUIRED_COMMENT_OPTIONS
  end
  params = arguments.params

  patch_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
end