Class: Gpr::Commands::Fetch

Inherits:
Base
  • Object
show all
Defined in:
lib/gpr/commands/fetch.rb

Constant Summary

Constants included from Gpr

APP_PATH, VERSION

Instance Method Summary collapse

Methods inherited from Base

inherited

Constructor Details

#initialize(thor) ⇒ Fetch

Returns a new instance of Fetch.



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/gpr/commands/fetch.rb', line 10

def initialize(thor)
  thor.class_eval do
    desc 'fetch', 'Fetch the registered repositories'
    def fetch(remote = 'origin', branch = nil, path = nil)
      if path.nil?
        repositories = repository_list
        repositories.each do |repository|
          repo_info = parse_repository(repository)

          puts "#{repo_info[:host].color(:yellow)} - #{repo_info[:repository].color(:blue)}"

          GitHelper.fetch(repository, remote, branch)
        end
      else
        repo_info = parse_repository(path)

        puts "#{repo_info[:host].color(:yellow)} - #{repo_info[:repository].color(:blue)}"

        GitHelper.fetch(path, remote, branch)
      end
    end
  end
end