Class: MGit::FetchCommand
Instance Method Summary
collapse
Methods inherited from Command
#check_arity, create, execute, instance_each, list, register_alias, register_command
Methods included from Output
#perror, #pinfo, #ptable, #pwarn
Instance Method Details
#arity ⇒ Object
31
32
33
|
# File 'lib/mgit/commands/fetch.rb', line 31
def arity
[nil, 0]
end
|
#description ⇒ Object
39
40
41
|
# File 'lib/mgit/commands/fetch.rb', line 39
def description
'fetch all remote repositories'
end
|
#execute(args) ⇒ Object
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
|
# File 'lib/mgit/commands/fetch.rb', line 5
def execute(args)
threads = []
Registry.each do |repo|
threads << Thread.new do
remotes, st = Open3.capture2('git remote', :chdir => repo.path)
if st.exitstatus != 0
perror "Failed to read remotes for repository #{repo.name}! Abort."
Thread.exit
end
remotes.split.each do |remote|
sout, st = Open3.capture2("git fetch #{remote}", :chdir => repo.path)
if st.exitstatus == 0
pinfo "Fetched #{remote} in repository #{repo.name}."
else
perror "Failed to fetch #{remote} in repository #{repo.name}! Abort."
break
end
end
end
end
threads.each { |t| t.join }
end
|
#usage ⇒ Object
35
36
37
|
# File 'lib/mgit/commands/fetch.rb', line 35
def usage
'fetch'
end
|