Module: Gitmore::Branches
- Included in:
- BranchMatcher
- Defined in:
- lib/branches.rb
Instance Method Summary collapse
Instance Method Details
#branches ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/branches.rb', line 3 def branches matching_repositories = [] repositories.each do |repository| Dir.chdir(repository) do case option when 'f', 'find' format_branch_info(repository, find) when 's', 'similar' format_branch_info(repository, find_similar) else # Default: prints repository branch info if currently on this branch if current_branch == matcher matching_repositories << repository format_branch_info(repository, `git branch --color`) end end end end if matcher == 'master' && matching_repositories.count < count non_matching_repositories = repositories - matching_repositories non_matching_count = non_matching_repositories.count puts "NOTICE: #{non_matching_count} branches checked out to something other than master!".colorize(:black).on_red non_matching_repositories.each do |name| puts name.colorize(:red) end end end |
#checkout ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/branches.rb', line 34 def checkout checkout = Proc.new { |repository| if branch_exists? && clean_status? unless current_branch == matcher `git checkout #{matcher}` end elsif !branch_exists? puts "branch #{matcher} does not exit on #{repository}" elsif !clean_status? puts repository.colorize(:black).on_red system('git status') end } perform(&checkout) end |
#fetches ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/branches.rb', line 51 def fetches fetch = Proc.new { |repository| puts "Fetching changes in #{repository}...".colorize(:black).on_blue.blink unless `git fetch`.to_s.empty? puts repository.colorize(:black).on_yellow end } perform(&fetch) end |
#pulls ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/branches.rb', line 62 def pulls pull = Proc.new { |repository| puts "Pulling changes in #{repository}...".colorize(:black).on_blue.blink system('git pull') } perform(&pull) end |