class Github::Issues::Labels
def add(user_name, repo_name, issue_id, *args)
github.issues.labels.add 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
github = Github.new
= Examples
Add labels to an issue
def add(user_name, repo_name, issue_id, *args) params = args.extract_options! params['data'] = args unless args.empty? set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params post_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end
def create(user_name, repo_name, params={})
github.issues.labels.create name: 'API', color: 'FFFFFF'
github = Github.new user: 'user-name', repo: 'repo-name'
= Examples
:color - Required string - 6 character hex code, without leading #
:name - Required string
= Inputs
Create a label
def create(user_name, repo_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo normalize! params filter! VALID_LABEL_INPUTS, params assert_required_keys(VALID_LABEL_INPUTS, params) post_request("/repos/#{user}/#{repo}/labels", params) end
def delete(user_name, repo_name, label_name, params={})
github.issues.labels.delete 'user-name', 'repo-name', 'label-name'
github = Github.new
= Examples
Delete a label
def delete(user_name, repo_name, label_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo assert_presence_of label_name normalize! params delete_request("/repos/#{user}/#{repo}/labels/#{label_name}", params) end
def get(user_name, repo_name, label_name, params={})
github.issues.labels.find 'user-name', 'repo-name', 'label-name'
github = Github.new
= Examples
Get a single label
def get(user_name, repo_name, label_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, label_name normalize! params get_request("/repos/#{user}/#{repo}/labels/#{label_name}", params) end
def initialize(options = {})
def initialize(options = {}) super(options) end
def list(user_name, repo_name, params={})
@github.issues.labels.list 'user-name', 'repo-name', issue_id: 'issue-id'
@github = Github.new
= Examples
List labels on an issue
github.issues.labels.list 'user-name', 'repo-name', milestone_id: 'milestone-id'
github = Github.new
= Examples
Get labels for every issue in a milestone
github.issues.labels.list { |label| ... }
github.issues.labels.list
github = Github.new user: 'user-name', repo: 'repo-name'
= Examples
List all labels for a repository
def list(user_name, repo_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo normalize! params response = if (milestone_id = params.delete('milestone_id')) get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params) elsif (issue_id = params.delete('issue_id')) get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) else get_request("/repos/#{user}/#{repo}/labels", params) end return response unless block_given? response.each { |el| yield el } end
def remove(user_name, repo_name, issue_id, params={})
github.issues.labels.remove 'user-name', 'repo-name', 'issue-id'
github = Github.new
= Examples
Remove all labels from an issue
lable_name: 'label-name'
github.issues.labels.remove 'user-name', 'repo-name', 'issue-id',
github = Github.new
= Examples
Remove a label from an issue
def remove(user_name, repo_name, issue_id, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params if (label_name = params.delete('label_name')) delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_name}", params) else delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end end
def replace(user_name, repo_name, issue_id, *args)
github.issues.labels.replace 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
github = Github.new
= Examples
Sending an empty array ([]) will remove all Labels from the Issue.
Replace all labels for an issue
def replace(user_name, repo_name, issue_id, *args) params = args.extract_options! params['data'] = args unless args.empty? set :user => user_name, :repo => repo_name assert_presence_of user, repo, issue_id normalize! params put_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params) end
def update(user_name, repo_name, label_name, params={})
name: 'API', color: "FFFFFF"
@github.issues.labels.update 'user-name', 'repo-name', 'label-name',
@github = Github.new
= Examples
:color - Required string-6 character hex code, without leading #
:name - Required string
= Inputs
Update a label
def update(user_name, repo_name, label_name, params={}) set :user => user_name, :repo => repo_name assert_presence_of user, repo, label_name normalize! params filter! VALID_LABEL_INPUTS, params assert_required_keys(VALID_LABEL_INPUTS, params) patch_request("/repos/#{user}/#{repo}/labels/#{label_name}", params) end