Skip to content

Instantly share code, notes, and snippets.

@fairchild
Created July 14, 2012 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fairchild/3109816 to your computer and use it in GitHub Desktop.
Save fairchild/3109816 to your computer and use it in GitHub Desktop.
script ot update github issue lables to work better with huboard
require'rubygems'
require 'octokit'
$organization='att-innovate'
$username='fairchild'
$token="yertoken"
def gh
@gh||= Octokit::Client.new(:login => $username, :oauth_token => $token)
end
def card_prep(repo)
new_labels={'Backlog'=>0, 'Working'=>1, 'Ready'=>2, 'Done'=>3}
puts "updating labels for repo: #{repo}"
names=gh.labels("#{$organization}/#{repo}").collect{|l| l.name}
new_labels.each do |l, i|
p newname="#{i} - #{l}"
names.each do |old|
p [:old, old]
if old.match /#{l}/
puts $&
gh.update_label("#{$organization}/#{repo}", old, {:name=>newname})
new_labels.delete(l)
end
end
end
new_labels.each{|l, i|
gh.add_label("#{$organization}/#{repo}", "#{i} - #{l}")
}
end
def add_points(repo)
new_labels={'1'=>0, 1=>1, 2=>2, '3'=>3, '5'=>5}
puts "updating labels for repo: #{repo}"
names=gh.labels("#{$organization}/#{repo}").collect{|l| l.name}
new_labels.each do |l, i|
puts "adding #{l} points label."
gh.add_label("#{$organization}/#{repo}", "#{l}") unless names.include?(l)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment