Module: Octokit::Client::Labels

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

Instance Method Summary collapse

Instance Method Details

#add_label(repo, label, color = "ffffff", options = {}) ⇒ Label

Add a label to a repository

Examples:

Add a new label “Version 1.0” with color “#cccccc”

Octokit.add_label("pengwynn/octokit", "Version 1.0", "cccccc")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • label (String)

    A new label

  • color (String) (defaults to: "ffffff")

    A color, in hex, without the leading #

Returns:

  • (Label)

    A Hashie of the new label

See Also:



39
40
41
# File 'lib/octokit/client/labels.rb', line 39

def add_label(repo, label, color="ffffff", options={})
  post("repos/#{Repository.new(repo)}/labels", options.merge({:name => label, :color => color}), 3)
end

#add_labels_to_an_issue(repo, number, labels) ⇒ Array

Add label(s) to an Issue

Examples:

Add two labels for pengwynn/octokit

Octokit.add_labels_to_an_issue("pengwynn/octokit", 10, ['V3 Transition', 'Improvement'])

Parameters:

  • repo (String, Repository, Hash)

    A Github repository

  • number (String)

    Number ID of the issue

  • labels (Array)

    An array of labels to apply to this Issue

Returns:

  • (Array)

    A list of the labels currently on the issue

See Also:



124
125
126
# File 'lib/octokit/client/labels.rb', line 124

def add_labels_to_an_issue(repo, number, labels)
  post("repos/#{Repository.new(repo)}/issues/#{number}/labels", labels, 3)
end

#delete_label!(repo, label, options = {}) ⇒ Response

Delete a label from a repository.

This deletes the label from the repository, and removes it from all issues.

Examples:

Delete the label “Version 1.0” from the repository.

Octokit.delete_label!("pengwynn/octokit", "Version 1.0")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • label (String)

    String name of the label

Returns:

  • (Response)

    A Faraday Response object

See Also:



69
70
71
# File 'lib/octokit/client/labels.rb', line 69

def delete_label!(repo, label, options={})
  delete("repos/#{Repository.new(repo)}/labels/#{CGI.escape(label)}", options, 3, true, true)
end

#label(repo, name, options = {}) ⇒ Label

Get single label for a repository

Examples:

Get the “V3 Addition” label from pengwynn/octokit

Octokit.labels("pengwynn/octokit")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • name (String)

    Name of the label

Returns:

  • (Label)

    A single label from the repository

See Also:



26
27
28
# File 'lib/octokit/client/labels.rb', line 26

def label(repo, name, options={})
  get("repos/#{Repository.new(repo)}/labels/#{CGI.escape(name)}", options, 3)
end

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

List available labels for a repository

Examples:

List labels for pengwynn/octokit

Octokit.labels("pengwynn/octokit")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

Returns:

  • (Array)

    A list of the labels across the repository

See Also:



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

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

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

List labels for a given issue

Examples:

List labels for pengwynn/octokit

Octokit.labels("pengwynn/octokit")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Array)

    A list of the labels currently on the issue

See Also:



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

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

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

Get labels for every issue in a milestone

Examples:

List all labels for milestone #2 on pengwynn/octokit

Octokit.labels_for_milestone("pengwynn/octokit", 2)

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the milestone

Returns:

  • (Array)

    A list of the labels across the milestone

See Also:



149
150
151
# File 'lib/octokit/client/labels.rb', line 149

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

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

Remove all label from an Issue

This removes the label from the Issue

Examples:

Remove all labels from Issue #23

Octokit.remove_all_labels("pengwynn/octokit", 23)

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

Returns:

  • (Array)

    A list of the labels currently on the issue

See Also:



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

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

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

Remove a label from an Issue

This removes the label from the Issue

Examples:

Remove the label “Version 1.0” from the repository.

Octokit.remove_label("pengwynn/octokit", 23, "Version 1.0")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • number (String)

    Number ID of the issue

  • label (String)

    String name of the label

Returns:

  • (Array)

    A list of the labels currently on the issue

See Also:



85
86
87
# File 'lib/octokit/client/labels.rb', line 85

def remove_label(repo, number, label, options={})
  delete("repos/#{Repository.new(repo)}/issues/#{number}/labels/#{CGI.escape(label)}", options, 3, true)
end

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

Replace all labels on an Issue

Examples:

Replace labels for pengwynn/octokit Issue #10

Octokit.replace_all_labels("pengwynn/octokit", 10, ['V3 Transition', 'Improvement'])

Parameters:

  • repo (String, Repository, Hash)

    A Github repository

  • number (String)

    Number ID of the issue

  • labels (Array)

    An array of labels to use as replacement

Returns:

  • (Array)

    A list of the labels currently on the issue

See Also:



137
138
139
# File 'lib/octokit/client/labels.rb', line 137

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

#update_label(repo, label, options = {}) ⇒ Label

Update a label

Examples:

Update the label “Version 1.0” with new color “#cceeaa”

Octokit.update_label("pengwynn/octokit", "Version 1.0", {:color => "cceeaa"})

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • label (String)

    The name of the label which will be updated

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

    A customizable set of options.

Options Hash (options):

  • :title (String)

    An updated label name

  • :color (String)

    An updated color value, in hex, without leading #

Returns:

  • (Label)

    A Hashie of the updated label

See Also:



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

def update_label(repo, label, options={})
  post("repos/#{Repository.new(repo)}/labels/#{CGI.escape(label)}", options, 3)
end