lib/git/branch/stray.rb in git-branch--stray-1.6.0 vs lib/git/branch/stray.rb in git-branch--stray-1.7.0

- old
+ new

@@ -1,10 +1,24 @@ require 'git/branch/stray/version' require 'English' require 'consenter' +class String + def colorize(color_code) + "\e[#{color_code}m#{self}\e[0m" + end + + def red + colorize('31') + end + + def yellow + colorize('33') + end +end + module Kernel def git(command) `git #{command}`.split($RS).each(&:strip!) end end @@ -65,19 +79,21 @@ (upstream_branch = to_branch_name[merge_ref]) && !remote_branch_names[remote].include?(upstream_branch) } end + # rubocop:disable Layout/LineLength def delete_stray_branches - stray_branches.each_consented('Delete stray branch "%s"') do |stray| + stray_branches.each_consented('Delete stray branch "%s"', inspector: :yellow) do |stray| system("git branch -d #{stray}") next if $CHILD_STATUS.success? - Array(stray).each_consented('Delete unmerged branch "%s"') do |unmerged| + Array(stray).each_consented('Delete unmerged branch "%s"', inspector: :red) do |unmerged| system("git branch -D #{unmerged}") end end end + # rubocop:enable Layout/LineLength def list_stray_branches stray_branches.each do |stray| system("git --no-pager branch -vv --list #{stray}") end