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:



229
230
231
# File 'lib/octokit/client/issues.rb', line 229

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

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

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

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

    A customizable set of options.

Options Hash (options):

  • :assignee (String)

    User login.

  • :milestone (Integer)

    Milestone number.

  • :labels (String)

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

Returns:

  • (Issue)

    The updated Issue

See Also:



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

def close_issue(repo, number, options={})
  patch("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "closed"}))
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", 'Updated Docs', 'Added some extra links')

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • title (String)

    A descriptive title

  • body (String)

    A concise description

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

    A customizable set of options.

Options Hash (options):

  • :assignee (String)

    User login.

  • :milestone (Integer)

    Milestone number.

  • :labels (String)

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

Returns:

  • (Issue)

    Your newly created issue

See Also:



99
100
101
# File 'lib/octokit/client/issues.rb', line 99

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

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

Delete a single comment

Examples:

Delete the comment #1194549 on an issue on pengwynn/octokit

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Comment number

Returns:

  • (Boolean)

    Success

See Also:



254
255
256
# File 'lib/octokit/client/issues.rb', line 254

def delete_comment(repo, number, options={})
  boolean_from_response(:delete, "repos/#{Repository.new(repo)}/issues/comments/#{number}", options)
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:



112
113
114
# File 'lib/octokit/client/issues.rb', line 112

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

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

Get a single comment attached to an issue

Examples:

Get comment #1194549 from an issue on pengwynn/octokit

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the comment

Returns:

  • (Comment)

    The specific comment in question

See Also:



216
217
218
# File 'lib/octokit/client/issues.rb', line 216

def issue_comment(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/comments/#{number}", options)
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:



204
205
206
# File 'lib/octokit/client/issues.rb', line 204

def issue_comments(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/#{number}/comments", options)
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:



280
281
282
# File 'lib/octokit/client/issues.rb', line 280

def issue_event(repo, number, options={})
  get("repos/#{Repository.new(repo)}/issues/events/#{number}", options)
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:



267
268
269
# File 'lib/octokit/client/issues.rb', line 267

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

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

Get all comments attached to issues for the repository

By default, Issue Comments are ordered by ascending ID.

Examples:

Get the comments for issues in the octokit repository

@client.issues_comments("pengwynn/octokit")

Get issues comments, sort by updated descending since a time

@client.issues_comments("pengwynn/octokit", {
  :sort => 'desc',
  :direction => 'down',
  :since => '2010-05-04T23:45:02Z'
})

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

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

    Optional parameters

Options Hash (options):

  • :sort (String)

    created or updated

  • :direction (String)

    asc or desc. Ignored without sort parameter.

  • :since (String)

    Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ

Returns:

  • (Array)

    List of issues comments.

See Also:



192
193
194
# File 'lib/octokit/client/issues.rb', line 192

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

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

List issues for a the authenticated user or repository

Examples:

List issues for a repository

Octokit.list_issues("sferik/rails_admin")

List issues for the authenticted user across repositories

@client = Octokit::Client.new(:login => 'foo', :password => 'bar')
@client.list_issues

Parameters:

  • repository (String, Repository, Hash) (defaults to: nil)

    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.

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



37
38
39
40
41
42
# File 'lib/octokit/client/issues.rb', line 37

def list_issues(repository = nil, options={})
  path = ''
  path = "repos/#{Repository.new(repository)}" if repository
  path += "/issues"
  get(path, options)
end

#org_issues(org, options = {}) ⇒ Array

List all issues for a given organization for the authenticated user

Examples:

List issues for the authenticted user across owned and member repositories

@client = Octokit::Client.new(:login => 'foo', :password => 'bar')
@client.user_issues

Parameters:

  • org (String)

    Organization GitHub username.

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

    A customizable set of options.

Options Hash (options):

  • :filter (String) — default: assigned

    State: assigned, created, mentioned, subscribed or closed.

  • :state (String) — default: open

    State: open or all.

  • :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.

  • :since (String)

    Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ

Returns:

  • (Array)

    A list of issues for a repository.

See Also:



82
83
84
# File 'lib/octokit/client/issues.rb', line 82

def org_issues(org, options={})
  get("/orgs/#{org}/issues", options)
end

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

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

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

    A customizable set of options.

Options Hash (options):

  • :assignee (String)

    User login.

  • :milestone (Integer)

    Milestone number.

  • :labels (String)

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

Returns:

  • (Issue)

    The updated Issue

See Also:



144
145
146
# File 'lib/octokit/client/issues.rb', line 144

def reopen_issue(repo, number, options={})
  patch("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "open"}))
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



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

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

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

Update a single comment on an issue

Examples:

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

Octokit.update_comment("pengwynn/octokit", 1194549, "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:



242
243
244
# File 'lib/octokit/client/issues.rb', line 242

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

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

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

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

    A customizable set of options.

Options Hash (options):

  • :assignee (String)

    User login.

  • :milestone (Integer)

    Milestone number.

  • :labels (String)

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

  • :state (String)

    State of the issue. open or closed

Returns:

  • (Issue)

    The updated Issue

See Also:



163
164
165
# File 'lib/octokit/client/issues.rb', line 163

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

#user_issues(options = {}) ⇒ Array

List all issues across owned and member repositories for the authenticated user

Examples:

List issues for the authenticted user across owned and member repositories

@client = Octokit::Client.new(:login => 'foo', :password => 'bar')
@client.user_issues

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • :filter (String) — default: assigned

    State: assigned, created, mentioned, subscribed or closed.

  • :state (String) — default: open

    State: open or all.

  • :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.

  • :since (String)

    Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ

Returns:

  • (Array)

    A list of issues for a repository.

See Also:



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

def user_issues(options={})
  get('/user/issues', options)
end