Guest User

Untitled

a guest
Mar 2nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #!/usr/local/bin/ruby
  2.  
  3. # This file creates a Git branch based on a specific Lighthouse ticket number
  4.  
  5. ### CONFIG
  6.  
  7. lh_token = 'mysecretkey'
  8. lh_username = false
  9. lh_password = false
  10. lh_account_name = "my_project"
  11. lh_project_id = 1
  12.  
  13. ### No need to modify below this line
  14.  
  15. require 'rubygems'
  16. require 'lighthouse-api'
  17.  
  18. ## Create a branch for lighthouse for the passed ticket number
  19.  
  20. ticket_number = ARGV[0]
  21.  
  22. Lighthouse.account = lh_account_name
  23.  
  24. #### You can use `authenticate` OR `token`
  25. if lh_token
  26. Lighthouse.token = lh_token
  27. elsif lh_username && lh_password
  28. Lighthouse.authenticate(lh_username, lh_password)
  29. else
  30. puts "This script is not configured yet. Open it up and change some of the config vars"
  31. exit
  32. end
  33.  
  34. if ticket_number && ticket_number.to_i > 0
  35. puts "Creating new branch for Lighthouse ticket ##{ticket_number}"
  36. `git checkout -b LH_#{ticket_number}`
  37. else
  38. puts "Please enter a valid ticket:\n"
  39. project = Lighthouse::Project.find(lh_project_id)
  40. project.tickets.each do |ticket|
  41. puts " [##{ticket.id} is #{ticket.state}] [Milestone: #{ticket.milestone_title}] #{ticket.title}\n" if !['resolved', 'invalid'].include?(ticket.state)
  42. end
  43. end
Add Comment
Please, Sign In to add comment