module Octokit::Client::Labels

Methods for the Issue Labels API

@see developer.github.com/v3/issues/labels/

Public Instance Methods

add_label(repo, label, color="ffffff", options = {}) click to toggle source

Add a label to a repository

@param repo [Integer, String, Repository, Hash] A GitHub repository @param label [String] A new label @param color [String] A color, in hex, without the leading # @return [Sawyer::Resource] The new label @see developer.github.com/v3/issues/labels/#create-a-label @example Add a new label “Version 1.0” with color “#cccccc”

Octokit.add_label("octokit/octokit.rb", "Version 1.0", "cccccc")
# File lib/octokit/client/labels.rb, line 43
def add_label(repo, label, color="ffffff", options = {})
  post "#{Repository.path repo}/labels", options.merge({:name => label, :color => color})
end
add_labels_to_an_issue(repo, number, labels) click to toggle source

Add label(s) to an Issue

@param repo [Integer, String, Repository, Hash] A Github repository @param number [Integer] Number ID of the issue @param labels [Array] An array of labels to apply to this Issue @return [Array<Sawyer::Resource>] A list of the labels currently on the issue @see developer.github.com/v3/issues/labels/#add-labels-to-an-issue @example Add two labels for octokit/octokit.rb

Octokit.add_labels_to_an_issue("octokit/octokit.rb", 10, ['V3 Transition', 'Improvement'])
# File lib/octokit/client/labels.rb, line 126
def add_labels_to_an_issue(repo, number, labels)
  post "#{Repository.path repo}/issues/#{number}/labels", labels
end
delete_label!(repo, label, options = {}) click to toggle source

Delete a label from a repository.

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

@param repo [Integer, String, Repository, Hash] A GitHub repository @param label [String] String name of the label @return [Boolean] Success @see developer.github.com/v3/issues/labels/#delete-a-label @example Delete the label “Version 1.0” from the repository.

Octokit.delete_label!("octokit/octokit.rb", "Version 1.0")
# File lib/octokit/client/labels.rb, line 72
def delete_label!(repo, label, options = {})
  boolean_from_response :delete, "#{Repository.path repo}/labels/#{label}", options
end
label(repo, name, options = {}) click to toggle source

Get single label for a repository

@param repo [Integer, String, Repository, Hash] A GitHub repository @param name [String] Name of the label @return [Sawyer::Resource] A single label from the repository @see developer.github.com/v3/issues/labels/#get-a-single-label @example Get the “V3 Addition” label from octokit/octokit.rb

Octokit.label("octokit/octokit.rb", "V3 Addition")
# File lib/octokit/client/labels.rb, line 30
def label(repo, name, options = {})
  get "#{Repository.path repo}/labels/#{name}", options
end
labels(repo, options = {}) click to toggle source

List available labels for a repository

@param repo [Integer, String, Repository, Hash] A GitHub repository @return [Array<Sawyer::Resource>] A list of the labels across the repository @see developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository @example List labels for octokit/octokit.rb

Octokit.labels("octokit/octokit.rb")
# File lib/octokit/client/labels.rb, line 18
def labels(repo, options = {})
  paginate "#{Repository.path repo}/labels", options
end
labels_for_issue(repo, number, options = {}) click to toggle source

List labels for a given issue

@param repo [Integer, String, Repository, Hash] A GitHub repository @param number [Integer] Number ID of the issue @return [Array<Sawyer::Resource>] A list of the labels currently on the issue @see developer.github.com/v3/issues/labels/#list-labels-on-an-issue @example List labels for octokit/octokit.rb, issue # 1

Octokit.labels_for_issue("octokit/octokit.rb", 1)
# File lib/octokit/client/labels.rb, line 113
def labels_for_issue(repo, number, options = {})
  paginate "#{Repository.path repo}/issues/#{number}/labels", options
end
labels_for_milestone(repo, number, options = {}) click to toggle source

Get labels for every issue in a milestone

@param repo [Integer, String, Repository, Hash] A GitHub repository @param number [Integer] Number ID of the milestone @return [Array<Sawyer::Resource>] A list of the labels across the milestone @see developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone @example List all labels for milestone #2 on octokit/octokit.rb

Octokit.labels_for_milestone("octokit/octokit.rb", 2)
# File lib/octokit/client/labels.rb, line 151
def labels_for_milestone(repo, number, options = {})
  paginate "#{Repository.path repo}/milestones/#{number}/labels", options
end
remove_all_labels(repo, number, options = {}) click to toggle source

Remove all label from an Issue

This removes the label from the Issue

@param repo [Integer, String, Repository, Hash] A GitHub repository @param number [Integer] Number ID of the issue @return [Boolean] Success of operation @see developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue @example Remove all labels from Issue #23

Octokit.remove_all_labels("octokit/octokit.rb", 23)
# File lib/octokit/client/labels.rb, line 101
def remove_all_labels(repo, number, options = {})
  boolean_from_response :delete, "#{Repository.path repo}/issues/#{number}/labels", options
end
remove_label(repo, number, label, options = {}) click to toggle source

Remove a label from an Issue

This removes the label from the Issue

@param repo [Integer, String, Repository, Hash] A GitHub repository @param number [Integer] Number ID of the issue @param label [String] String name of the label @return [Array<Sawyer::Resource>] A list of the labels currently on the issue @see developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue @example Remove the label “Version 1.0” from the repository.

Octokit.remove_label("octokit/octokit.rb", 23, "Version 1.0")
# File lib/octokit/client/labels.rb, line 87
def remove_label(repo, number, label, options = {})
  delete "#{Repository.path repo}/issues/#{number}/labels/#{label}", options
end
replace_all_labels(repo, number, labels, options = {}) click to toggle source

Replace all labels on an Issue

@param repo [Integer, String, Repository, Hash] A Github repository @param number [Integer] Number ID of the issue @param labels [Array] An array of labels to use as replacement @return [Array<Sawyer::Resource>] A list of the labels currently on the issue @see developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue @example Replace labels for octokit/octokit.rb Issue #10

Octokit.replace_all_labels("octokit/octokit.rb", 10, ['V3 Transition', 'Improvement'])
# File lib/octokit/client/labels.rb, line 139
def replace_all_labels(repo, number, labels, options = {})
  put "#{Repository.path repo}/issues/#{number}/labels", labels
end
update_label(repo, label, options = {}) click to toggle source

Update a label

@param repo [Integer, String, Repository, Hash] A GitHub repository @param label [String] The name of the label which will be updated @param options [Hash] A customizable set of options. @option options [String] :name An updated label name @option options [String] :color An updated color value, in hex, without leading # @return [Sawyer::Resource] The updated label @see developer.github.com/v3/issues/labels/#update-a-label @example Update the label “Version 1.0” with new color “#cceeaa”

Octokit.update_label("octokit/octokit.rb", "Version 1.0", {:color => "cceeaa"})
# File lib/octokit/client/labels.rb, line 58
def update_label(repo, label, options = {})
  patch "#{Repository.path repo}/labels/#{label}", options
end