multipull 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f1d52ce7937a9cbdf187fb67e70da3d855674c967f2d933a236d7ae11260f53
4
- data.tar.gz: 3d852fa553f4fbfaa5777ce0a05edbfa4a43361023b5b6357f43f1cb2e603904
3
+ metadata.gz: 856b4c5e02bb5298fc6efb851bb844eece135e7bee48341f631f8d8a17958d02
4
+ data.tar.gz: 3836ec83f7a4ca566aa560179eaf93d1d9eb3ca1ad933c66421a74caf43bcd01
5
5
  SHA512:
6
- metadata.gz: 66e216ce8dfc83b588d5fb20affb37daf38e9b54c203b2763d0b8218e5cefcf640261ca5a2d7e5c807e4a07cef8b1be1cbd7d99aaa1c7c7f1bd5076272b5c9ce
7
- data.tar.gz: e13b11f4b9b6ffaa15e1f9da814d8bcef561054444cf06097133c50f32350ed57b66545d8395f8cd08943261b148717e8a36b7f4f98fb541289b2b8e83017609
6
+ metadata.gz: ac920ccd6dafec05aadce61a4529c3d1ea89a3251ebf01be24b763a3da2c435aacaef4d23cc3bf5b6cb21bea0f0dd2c65c24f99d72868761a521f8b727a9077d
7
+ data.tar.gz: e4f9d2111542c94983691ee4c2becd3ad9c30ce35c5bff8defd8d8294bf1251bfbaaff98d1c577efa897d3a55b5d8e5a1e50180e310c09a5dc93df32bf76ecb0
@@ -10,6 +10,7 @@ module Multipull
10
10
  def initialize
11
11
  # @options = {}
12
12
  @dirs = []
13
+ @git_opts = []
13
14
  end
14
15
 
15
16
  def run
@@ -20,19 +21,25 @@ module Multipull
20
21
  private
21
22
 
22
23
  def parse_options
23
- OptionParser.new do |opts|
24
- opts.banner = 'Usage: multipull [options] [dir...]'
24
+ opts = OptionParser.new
25
+ opts.banner = 'Usage: multipull [options] [dir...]'
25
26
 
26
- opts.on('-v', '--version', 'Show version') do
27
- puts VERSION
28
- exit
29
- end
27
+ opts.on('--version', 'Show version') do
28
+ puts "multipull #{VERSION}"
29
+ exit
30
+ end
30
31
 
31
- opts.on('-h', '--help', 'Show help') do
32
- puts opts
33
- exit
34
- end
35
- end.parse!
32
+ opts.on('--help', 'Show help') do
33
+ puts opts
34
+ exit
35
+ end
36
+
37
+ begin
38
+ opts.parse!
39
+ rescue OptionParser::InvalidOption => e
40
+ @git_opts += e.args
41
+ retry
42
+ end
36
43
 
37
44
  @dirs = ARGV.empty? ? ['.'] : ARGV
38
45
  end
@@ -49,14 +56,40 @@ module Multipull
49
56
  puts magenta("#{dir} is not a directory")
50
57
  next
51
58
  end
59
+
60
+ skipped = []
61
+ succeeded = []
62
+ failed = []
52
63
  Dir.chdir(dir) do
53
64
  Dir.glob('*/').each do |subdir|
54
- puts blue(bold(subdir))
55
65
  Dir.chdir(subdir) do
56
- system('git pull')
66
+ dirname = subdir.delete_suffix('/')
67
+ if File.directory?('.git')
68
+ puts blue(bold(dirname))
69
+ else
70
+ skipped << dirname
71
+ next
72
+ end
73
+ if system("git pull #{@git_opts.join(' ')}")
74
+ succeeded << dirname
75
+ else
76
+ failed << dirname
77
+ end
57
78
  end
58
79
  end
59
80
  end
81
+ unless skipped.empty?
82
+ warn \
83
+ bold('Skipped : ') + skipped.join(' ')
84
+ end
85
+ unless succeeded.empty?
86
+ warn \
87
+ bold(green('Succeeded : ')) + succeeded.join(' ')
88
+ end
89
+ unless failed.empty?
90
+ warn \
91
+ bold(magenta('Failed : ')) + failed.join(' ')
92
+ end
60
93
  end
61
94
  end
62
95
  end
@@ -6,6 +6,10 @@ module Multipull
6
6
  "\e[1m#{s}\e[22m"
7
7
  end
8
8
 
9
+ def green(s)
10
+ "\e[32m#{s}\e[0m"
11
+ end
12
+
9
13
  def cyan(s)
10
14
  "\e[36m#{s}\e[0m"
11
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Multipull
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multipull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Git pull multiple repositories at once
14
14
  email:
@@ -28,7 +28,7 @@ homepage: https://github.com/kojix2/multipull
28
28
  licenses:
29
29
  - MIT
30
30
  metadata: {}
31
- post_install_message:
31
+ post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubygems_version: 3.3.7
47
- signing_key:
47
+ signing_key:
48
48
  specification_version: 4
49
49
  summary: Git pull multiple repositories at once
50
50
  test_files: []