Created
August 20, 2008 00:09
-
-
Save davidjrice/6257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_support' | |
require 'vendor/plugins/lighthouse-api/lib/lighthouse' | |
usage = "USAGE: ruby lighthouse_reassign api-key account-subdomain project-id milestone_to_move_from milestone_to_move_to" | |
token = $ARGV[0] | |
subdomain = $ARGV[1] | |
project_id = $ARGV[2].to_i | |
milestone_to_move_from = $ARGV[3].to_i | |
milestone_to_move_to = $ARGV[4].to_i | |
unless (subdomain && token && project_id && milestone_to_move_from && milestone_to_move_to) | |
puts usage | |
exit | |
end | |
begin | |
Lighthouse.account = subdomain | |
Lighthouse.token = token | |
@project = Lighthouse::Project.find(project_id) | |
puts "="*78 | |
puts "Project Selected: " + @project.name | |
puts "Finding tickets..." | |
puts "="*78 | |
# TODO: Print list of milestones for selected project and get user input | |
# of milestones to move tickets between. gets doesn't work after requiring | |
# active_support, weird. | |
# @project.milestones.each do |m| | |
# puts "#{m.id}: #{m.title}, (#{m.open_tickets_count})" | |
# end | |
@tickets_to_move = [] | |
page = 1 | |
while !(tickets = Lighthouse::Ticket.find(:all, :params => {:project_id => project_id, :q => "state:open", :page => page })).empty? | |
tickets.each do |t| | |
if t.milestone_id == milestone_to_move_from | |
puts "#{t.id}: #{t.title}" | |
@tickets_to_move << t | |
end | |
end | |
page += 1 | |
end | |
puts "="*78 | |
puts "Found #{@tickets_to_move.size} tickets." | |
puts "Moving them to milestone #{milestone_to_move_to}..." | |
puts "="*78 | |
@tickets_to_move.each do |t| | |
puts "#{t.id}: #{t.title}" | |
t.milestone_id = milestone_to_move_to | |
t.save | |
end | |
puts "ktnxbai!" | |
rescue | |
puts "There was an error contacting Lighthouse. Check your details." | |
puts usage | |
exit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment