Class: LighthouseBranch
- Inherits:
-
Object
- Object
- LighthouseBranch
- Defined in:
- lib/lighthouse_branch.rb
Class Method Summary collapse
- .branch_name(args) ⇒ Object
- .get_lighthouse_account ⇒ Object
- .invoke(args) ⇒ Object
- .repo ⇒ Object
- .ticket(id) ⇒ Object
- .usage ⇒ Object
Class Method Details
.branch_name(args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lighthouse_branch.rb', line 31 def self.branch_name(args) unless @branch_name if(Float(args.first) rescue false) ticket_id = args.shift.to_i @branch_name = "#{ticket_id}-#{ticket(ticket_id).title.gsub(/[^\w ]/, '').gsub(/[^a-z0-9]+/i, '-').downcase}" else @branch_name = repo.head.name end end return @branch_name end |
.get_lighthouse_account ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lighthouse_branch.rb', line 12 def self.get_lighthouse_account Lighthouse.account = repo.config["lighthouse.account"] Lighthouse.token = repo.config["lighthouse.token"] begin @project = Lighthouse::Project.find(repo.config["lighthouse.project"]) rescue puts "You must add your lighthouse account info to git config:" puts "git config lighthouse.account [lighthouse account subdomain]" puts "git config lighthouse.token [lighthouse API token]" puts "git config lighthouse.project [lighthouse project id]" exit end end |
.invoke(args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lighthouse_branch.rb', line 44 def self.invoke(args) get_lighthouse_account command = :default if Command::Base.command_regexes.select{ |command| args.first =~ command }.empty? branch = branch_name(args) ticket_id = branch.to_i if ticket_id == 0 usage exit end else command = args.shift branch = branch_name(args) ticket_id = branch.to_i end Command::Base.invoke(command, branch, ticket_id, args) end |
.repo ⇒ Object
8 9 10 |
# File 'lib/lighthouse_branch.rb', line 8 def self.repo @repo ||= Grit::Repo.new(Dir.pwd) end |
.ticket(id) ⇒ Object
27 28 29 |
# File 'lib/lighthouse_branch.rb', line 27 def self.ticket(id) Lighthouse::Ticket.find(id, :params => { :project_id => @project.id }) end |
.usage ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/lighthouse_branch.rb', line 64 def self.usage puts "If ticket_id is not supplied, the ticket will be determined by the current branch name." puts "lh-branch [ticket_id] ([remote_name])" puts "lh-branch push [ticket_id] [remote_name]" puts "lh-branch pull [ticket_id] [remote_name]" puts "lh-branch merge [ticket_id]" puts "lh-branch checkout [ticket_id]" puts "lh-branch update [ticket_id] [message] ([extra])" puts "lh-branch delete [ticket_id] ([remote_name])" puts "lh-branch delete_remote [ticket_id] [remote_name]" puts "lh-branch resolve [ticket_id] [message]" end |