class GitTools::Branches::Branch
Constants
- DATE_REGEXP
Attributes
age[R]
name[R]
remote[R]
Public Class Methods
age(branch)
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 187 def self.age(branch) cmd = "git log --shortstat --date=iso -n 1 #{branch}" time = DATE_REGEXP.match(`#{cmd}`) if time.nil? raise "Error due to unexpected git output on command: #{cmd}." else Time.parse(time[1]) end end
executor()
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 197 def self.executor ActionExecutor.new end
new(name, remote)
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 205 def initialize(name, remote) @name = name @remote = remote @age = self.class.age(normalized_name) end
Public Instance Methods
confirm_remove(message, prompt)
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 219 def confirm_remove(message, prompt) self.class.executor.execute(remove_branch_action, message, prompt) end
normalized_name()
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 211 def normalized_name local? ? name : "#{remote}/#{name}" end
remove!(message)
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 215 def remove!(message) self.class.executor.execute(remove_branch_action, message) end
to_s()
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 223 def to_s name end
Private Instance Methods
local?()
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 229 def local? remote.nil? end
remove_branch_action()
click to toggle source
# File lib/git_tools/branches/cleaner.rb, line 233 def remove_branch_action local? ? "git branch -d #{name}" : "git push #{remote} :#{name}" end