class Rlt::Commands::Close
Public Class Methods
any_conflict?()
click to toggle source
# File lib/rlt/commands/close.rb, line 47 def self.any_conflict? result = Utils::GitUtil.any_conflict? print_conflict_error if result result end
default_branch(config)
click to toggle source
# File lib/rlt/commands/close.rb, line 36 def self.default_branch(config) config['default_branch'] || 'master' end
default_branch_now?(default_branch)
click to toggle source
# File lib/rlt/commands/close.rb, line 30 def self.default_branch_now?(default_branch) result = Utils::GitUtil.current_branch_name == default_branch print_default_branch_now_error(default_branch) if result result end
delete_branch(current_branch_name)
click to toggle source
# File lib/rlt/commands/close.rb, line 67 def self.delete_branch(current_branch_name) Utils::GitUtil.delete_branch(current_branch_name, print_info: true) Utils::GitUtil.remotes.each do |remote| Utils::GitUtil.safely_delete_remote_branch(remote, current_branch_name, print_info: true) end end
merge_back_and_forth(current_branch_name, default_branch)
click to toggle source
# File lib/rlt/commands/close.rb, line 40 def self.merge_back_and_forth(current_branch_name, default_branch) Utils::GitUtil.merge_from(default_branch, print_info: true) return if any_conflict? Utils::GitUtil.checkout(default_branch, print_info: true) Utils::GitUtil.merge_from(current_branch_name, print_info: true) end
print_conflict_error()
click to toggle source
# File lib/rlt/commands/close.rb, line 62 def self.print_conflict_error Utils::Logger.error 'Aborting the process due to the conflict.' Utils::Logger.error 'Resolve them first, and try it again.' end
print_default_branch_now_error(default_branch)
click to toggle source
# File lib/rlt/commands/close.rb, line 58 def self.print_default_branch_now_error(default_branch) Utils::Logger.error "You cannot close `#{default_branch}`." end
print_uncommitted_changes_error()
click to toggle source
# File lib/rlt/commands/close.rb, line 53 def self.print_uncommitted_changes_error Utils::Logger.error 'There are uncommitted changes.' Utils::Logger.error 'Commit them first!' end
run(config)
click to toggle source
# File lib/rlt/commands/close.rb, line 6 def self.run(config) default_branch = default_branch(config) current_branch_name = Utils::GitUtil.current_branch_name return if should_stop?(default_branch) run_internal(current_branch_name, default_branch) Utils::Logger.info "Done closing `#{current_branch_name}`." end
run_internal(current_branch_name, default_branch)
click to toggle source
# File lib/rlt/commands/close.rb, line 14 def self.run_internal(current_branch_name, default_branch) merge_back_and_forth(current_branch_name, default_branch) delete_branch(current_branch_name) end
should_stop?(default_branch)
click to toggle source
# File lib/rlt/commands/close.rb, line 19 def self.should_stop?(default_branch) return true if uncommitted_changes? return true if default_branch_now?(default_branch) end
uncommitted_changes?()
click to toggle source
# File lib/rlt/commands/close.rb, line 24 def self.uncommitted_changes? result = Utils::GitUtil.uncommitted_change? print_uncommitted_changes_error if result result end