public
Last active

  • Download Gist
github_lighthouse.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.