Created
September 8, 2010 21:40
-
-
Save smathy/570887 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
def run | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
lh_api = "c969b955085e607c2450a58a0f3cde66be4f7c5f"; | |
gem 'rails', '2.3.5' | |
require 'lighthouse' | |
Lighthouse.account = 'amco' | |
Lighthouse.token = lh_api | |
project = `git config remote.origin.url`.match( %r{[email protected]:[^/]+/(.*).git})[1] | |
user_id = `git config lighthouse.userid`.chomp | |
projects = { | |
'AMCO-Online' => 38551, | |
'AMCO-World' => 38553, | |
'Teacher-Home' => 38554, | |
'SEQ' => 38556, | |
'Visor' => 38552, | |
'ops' => 40578, | |
} | |
ticket = ARGV.shift | |
t = Lighthouse::Ticket.find( ticket.to_i, :params => { :project_id => projects[project] } ) | |
if t.state != 'open' | |
prompt "Ticket #{ticket} is state #{t.state}, continue? [Y/n] " | |
end | |
if t.assigned_user_id and t.assigned_user_id != user_id | |
u = Lighthouse::User.find t.assigned_user_id | |
prompt "Ticket #{ticket} is assigned to #{u.name}, continue? [Y/n] " | |
end | |
system "git checkout -b t#{ticket} master" | |
t.state = 'open' | |
t.assigned_user_id = user_id | |
t.save | |
end | |
def prompt message | |
print message | |
answer = gets.chomp.downcase | |
return if answer.blank? or answer == 'y' | |
exit | |
end | |
run | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment