class GradesFirst::BranchCommand
Implemenation of a Thor command for enhancing git branch to include PivotalTracker
information such as the story state, name and url.
Public Class Methods
description()
click to toggle source
Description of the gf branch Thor command that will be used in the commandline help.
# File lib/gradesfirst/branch_command.rb, line 11 def self.description 'List git branches with related PivotalTracker story information.' end
new()
click to toggle source
# File lib/gradesfirst/branch_command.rb, line 15 def initialize @enhanced_branches = [] end
Public Instance Methods
execute()
click to toggle source
Performs the gf branch Thor command.
# File lib/gradesfirst/branch_command.rb, line 20 def execute git_response = git_branch git_response.each_line do |branch| @enhanced_branches << enhanced_branch(branch.rstrip) end nil end
response()
click to toggle source
Output response of the gf branch Thor command that contains the PivotalTracker
enhanced branch names.
# File lib/gradesfirst/branch_command.rb, line 30 def response @enhanced_branches.join("\n") + "\n" end
Private Instance Methods
enhanced_branch(branch)
click to toggle source
# File lib/gradesfirst/branch_command.rb, line 36 def enhanced_branch(branch) story = find_story_by_branch(branch) if story status = story['current_state'].capitalize "#{branch} [#{status}] #{story['name']} (#{story['url']})" else branch end end
find_story_by_branch(branch)
click to toggle source
# File lib/gradesfirst/branch_command.rb, line 46 def find_story_by_branch(branch) if story_id(branch) PivotalTracker.stories[story_id(branch)].get else nil end end
git_branch()
click to toggle source
# File lib/gradesfirst/branch_command.rb, line 54 def git_branch `git branch` end