Skip to content

Instantly share code, notes, and snippets.

@nshbrown
Created March 6, 2009 20:05
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 nshbrown/75043 to your computer and use it in GitHub Desktop.
Save nshbrown/75043 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
# This file creates a Git branch based on a specific Lighthouse ticket number
### CONFIG
lh_token = 'mysecretkey'
lh_username = false
lh_password = false
lh_account_name = "my_project"
lh_project_id = 1
### No need to modify below this line
require 'rubygems'
require 'lighthouse-api'
## Create a branch for lighthouse for the passed ticket number
ticket_number = ARGV[0]
Lighthouse.account = lh_account_name
#### You can use `authenticate` OR `token`
if lh_token
Lighthouse.token = lh_token
elsif lh_username && lh_password
Lighthouse.authenticate(lh_username, lh_password)
else
puts "This script is not configured yet. Open it up and change some of the config vars"
exit
end
if ticket_number && ticket_number.to_i > 0
puts "Creating new branch for Lighthouse ticket ##{ticket_number}"
`git checkout -b LH_#{ticket_number}`
else
puts "Please enter a valid ticket:\n"
project = Lighthouse::Project.find(lh_project_id)
project.tickets.each do |ticket|
puts " [##{ticket.id} is #{ticket.state}] [Milestone: #{ticket.milestone_title}] #{ticket.title}\n" if !['resolved', 'invalid'].include?(ticket.state)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment