Module: Octokit::Client::Issues

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

Overview

Methods for the Issues API

Instance Method Summary collapse

Instance Method Details

#add_comment(repo, number, comment, options = {}) ⇒ Sawyer::Resource

Add a comment to an issue

Examples:

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

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Issue number

  • comment (String)

    Comment to be added

Returns:

  • (Sawyer::Resource)

    Comment

See Also:



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

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 = {}) ⇒ Sawyer::Resource

Close an issue

Examples:

Close Issue #25 from octokit/octokit.rb

Octokit.close_issue("octokit/octokit.rb", "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:

  • (Sawyer::Resource)

    The updated Issue

See Also:



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

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

#create_issue(repo, title, body, options = {}) ⇒ Sawyer::Resource 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:

  • (Sawyer::Resource)

    Your newly created issue

See Also:



92
93
94
95
96
97
98
99
100
# File 'lib/octokit/client/issues.rb', line 92

def create_issue(repo, title, body, options = {})
  options[:labels] = case options[:labels]
                     when String
                       options[:labels].split(",").map(&:strip)
                     when Array
                       options[:labels]
                     end
  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 octokit/octokit.rb

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (Integer)

    Comment number

Returns:

  • (Boolean)

    Success

See Also:



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

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

#issue(repo, number, options = {}) ⇒ Sawyer::Resource

Get a single issue from a repository

Examples:

Get issue #25 from octokit/octokit.rb

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Sawyer::Resource)

    The issue you requested, if it exists

See Also:



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

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

#issue_comment(repo, number, options = {}) ⇒ Sawyer::Resource

Get a single comment attached to an issue

Examples:

Get comment #1194549 from an issue on octokit/octokit.rb

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the comment

Returns:

  • (Sawyer::Resource)

    The specific comment in question

See Also:



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

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

#issue_comments(repo, number, options = {}) ⇒ Array<Sawyer::Resource>

Get all comments attached to an issue

Examples:

Get comments for issue #25 from octokit/octokit.rb

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

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Array<Sawyer::Resource>)

    Array of comments that belong to an issue

See Also:



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

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

#issues_comments(repo, options = {}) ⇒ Array<Sawyer::Resource>

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("octokit/octokit.rb")

Get issues comments, sort by updated descending since a time

@client.issues_comments("octokit/octokit.rb", {
  :sort => 'desc',
  :direction => 'asc',
  :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<Sawyer::Resource>)

    List of issues comments.

See Also:



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

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

#list_issues(repository = nil, options = {}) ⇒ Array<Sawyer::Resource> 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 (Sawyer::Resource) (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<Sawyer::Resource>)

    A list of issues for a repository.

See Also:



29
30
31
32
33
34
35
# File 'lib/octokit/client/issues.rb', line 29

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

  paginate path, options
end

#org_issues(org, options = {}) ⇒ Array<Sawyer::Resource>

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 (Sawyer::Resource) (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<Sawyer::Resource>)

    A list of issues for a repository.

See Also:



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

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

#reopen_issue(repo, number, options = {}) ⇒ Sawyer::Resource

Reopen an issue

Examples:

Reopen Issue #25 from octokit/octokit.rb

Octokit.reopen_issue("octokit/octokit.rb", "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:

  • (Sawyer::Resource)

    The updated Issue

See Also:



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

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

#update_comment(repo, number, comment, options = {}) ⇒ Sawyer::Resource

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 octokit/octokit.rb

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

  • (Sawyer::Resource)

    Comment

See Also:



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

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 = {}) ⇒ Sawyer::Resource

Update an issue

Examples:

Change the title of Issue #25

Octokit.update_issue("octokit/octokit.rb", "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:

  • (Sawyer::Resource)

    The updated Issue

See Also:



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

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<Sawyer::Resource>

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 (Sawyer::Resource) (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<Sawyer::Resource>)

    A list of issues for a repository.

See Also:



54
55
56
# File 'lib/octokit/client/issues.rb', line 54

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