Module: Octokit::Client::Issues

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

Instance Method Summary collapse

Instance Method Details

#add_comment(repo, number, comment, options = {}) ⇒ Comment

Add a comment to an issue

Examples:

Add the comment “Almost to v1” to Issue #23 on pengwynn/octokit

Octokit.add_comment("pengwynn/octokit", 23, "Almost to v1")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Issue number

  • comment (String)

    Comment to be added

Returns:

  • (Comment)

    A JSON encoded Comment

See Also:



142
143
144
# File 'lib/octokit/client/issues.rb', line 142

def add_comment(repo, number, comment, options={})
  post("repos/#{Repository.new(repo)}/issues/#{number}/comments", options.merge({:body => comment}), 3)
end

#close_issue(repo, number, options = {}) ⇒ Issue

Note:

This implementation needs to be adjusted with switch to API v3

Close an issue

Examples:

Close Issue #25 from pengwynn/octokit

Octokit.close_issue("pengwynn/octokit", "25")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Issue)

    The updated Issue

See Also:



75
76
77
# File 'lib/octokit/client/issues.rb', line 75

def close_issue(repo, number, options={})
  post("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "closed"}), 3)
end

#create_issue(repo, title, body, options = {}) ⇒ Issue Also known as: open_issue

Create an issue for a repository

Examples:

Create a new Issues for a repository

Octokit.create_issue("sferik/rails_admin")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • title (String)

    A descriptive title

  • body (String)

    A concise description

Returns:

  • (Issue)

    Your newly created issue

See Also:



48
49
50
# File 'lib/octokit/client/issues.rb', line 48

def create_issue(repo, title, body, options={})
  post("repos/#{Repository.new(repo)}/issues", options.merge({:title => title, :body => body}), 3)
end

#delete_comment(repo, number, options = {}) ⇒ Response

Delete a single comment

Examples:

Delete the comment “I’ve started this on my 25-issue-comments-v3 fork” on Issue #25 on pengwynn/octokit

Octokit.delete_comment("pengwynn/octokit", 1194549)

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Comment number

Returns:

  • (Response)

    A response object with status

See Also:



167
168
169
# File 'lib/octokit/client/issues.rb', line 167

def delete_comment(repo, number, options={})
  delete("repos/#{Repository.new(repo)}/issues/comments/#{number}", options, 3, true, true)
end

#issue(repo, number, options = {}) ⇒ Issue

Get a single issue from a repository

Examples:

Get issue #25 from pengwynn/octokit

Octokit.issue("pengwynn/octokit", "25")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Issue)

    The issue you requested, if it exists

See Also:



61
62
63
# File 'lib/octokit/client/issues.rb', line 61

def issue(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/#{number}", options, 3)
end

#issue_comment(repo, number, options = {}) ⇒ Comment

Get a single comment attached to an issue

Examples:

Get comments for issue #25 from pengwynn/octokit

Octokit.issue_comments("pengwynn/octokit", "25")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Comment)

    The specific comment in question

See Also:



129
130
131
# File 'lib/octokit/client/issues.rb', line 129

def issue_comment(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/comments/#{number}", options, 3)
end

#issue_comments(repo, number, options = {}) ⇒ Array

Get all comments attached to an issue

Examples:

Get comments for issue #25 from pengwynn/octokit

Octokit.issue_comments("pengwynn/octokit", "25")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Array)

    Array of comments that belong to an issue

See Also:



117
118
119
# File 'lib/octokit/client/issues.rb', line 117

def issue_comments(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/#{number}/comments", options, 3)
end

#issue_event(repo, number, options = {}) ⇒ Event

Get information on a single Issue Event

Examples:

Get Event information for ID 3094334 (a pull request was closed)

Octokit.issue_event("pengwynn/octokit", 3094334)

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Event number

Returns:

  • (Event)

    A single Event for an Issue

See Also:



194
195
196
# File 'lib/octokit/client/issues.rb', line 194

def issue_event(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/events/#{number}", options, 3)
end

#issue_events(repo, number, options = {}) ⇒ Array

List events for an Issue

Examples:

List all issues events for issue #38 on pengwynn/octokit

Octokit.issue_events("pengwynn/octokit", 38)

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Issue number

Returns:

  • (Array)

    Array of events for that issue

See Also:



181
182
183
# File 'lib/octokit/client/issues.rb', line 181

def issue_events(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/#{number}/events", options, 3)
end

#list_issues(repository, options = {}) ⇒ Array Also known as: issues

List issues for a repository

Examples:

List issues for a repository

Octokit.list_issues("sferik/rails_admin")

Parameters:

  • repository (String, Repository, Hash)

    A GitHub repository.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :milestone (Integer)

    Milestone number.

  • :state (String) — default: open

    State: open or closed.

  • :assignee (String)

    User login.

  • :mentioned (String)

    User login.

  • :labels (String)

    List of comma separated Label names. Example: bug,ui,@high.

  • :sort (String) — default: created

    Sort: created, updated, or comments.

  • :direction (String) — default: desc

    Direction: asc or desc.

  • :page (Integer) — default: 1

    Page number.

Returns:

  • (Array)

    A list of issues for a repository.

See Also:



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

def list_issues(repository, options={})
  get("repos/#{Repository.new(repository)}/issues", options, 3)
end

#reopen_issue(repo, number, options = {}) ⇒ Issue

Note:

This implementation needs to be adjusted with switch to API v3

Reopen an issue

Examples:

Reopen Issue #25 from pengwynn/octokit

Octokit.reopen_issue("pengwynn/octokit", "25")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Issue)

    The updated Issue

See Also:



89
90
91
# File 'lib/octokit/client/issues.rb', line 89

def reopen_issue(repo, number, options={})
  post("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "open"}), 3)
end

#search_issues(repo, search_term, state = 'open', options = {}) ⇒ Array

Search issues within a repository

Examples:

Search for ‘test’ in the open issues for sferik/rails_admin

Octokit.search_issues("sferik/rails_admin", 'test', 'open')

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • search_term (String)

    The term to search for

  • state (String) (defaults to: 'open')

    :state (open) open or closed.

Returns:

  • (Array)

    A list of issues matching the search term and state

See Also:



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

def search_issues(repo, search_term, state='open', options={})
  get("legacy/issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options, 3)['issues']
end

#update_comment(repo, number, comment, options = {}) ⇒ Comment

Update a single comment on an issue

Examples:

Update the comment “I’ve started this on my 25-issue-comments-v3 fork” on Issue #25 on pengwynn/octokit

Octokit.update_comment("pengwynn/octokit", 25, "Almost to v1, added this on my fork")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Comment number

  • comment (String)

    Body of the comment which will replace the existing body.

Returns:

  • (Comment)

    A JSON encoded Comment

See Also:



155
156
157
# File 'lib/octokit/client/issues.rb', line 155

def update_comment(repo, number, comment, options={})
  post("repos/#{Repository.new(repo)}/issues/comments/#{number}", options.merge({:body => comment}), 3)
end

#update_issue(repo, number, title, body, options = {}) ⇒ Issue

Note:

This implementation needs to be adjusted with switch to API v3

Update an issue

Examples:

Change the title of Issue #25

Octokit.update_issue("pengwynn/octokit", "25", "A new title", "the same body"")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

  • title (String)

    Updated title for the issue

  • body (String)

    Updated body of the issue

Returns:

  • (Issue)

    The updated Issue

See Also:



105
106
107
# File 'lib/octokit/client/issues.rb', line 105

def update_issue(repo, number, title, body, options={})
  post("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:title => title, :body => body}), 3)
end