multipull 0.0.0 → 0.0.1

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: d5b0438e618d1ba1be329f027bb3bb449763a7f76f517b956f052608ffc62610
4
- data.tar.gz: 272f5c45b26d43d9d8e366d3ba4c3bb43300eb219a13215aba382c3f1406f12a
3
+ metadata.gz: 2f1d52ce7937a9cbdf187fb67e70da3d855674c967f2d933a236d7ae11260f53
4
+ data.tar.gz: 3d852fa553f4fbfaa5777ce0a05edbfa4a43361023b5b6357f43f1cb2e603904
5
5
  SHA512:
6
- metadata.gz: f9a218a785d6bf9165f642fbc57f43485a1c49f44d3b00f52a9a908cdec5c208b466138bdce9c0d3377d4ba2f9a36b8527fd79df0898d663605d95f8ea6822fa
7
- data.tar.gz: 0f5b6075aa72ba0ab1dcb6d51ee84a7c885f0bda10098631cbcc426d2b37e9bf6c467d1094368c096442212c6ba96e55e45ccc9a397cf7973d012ecbc899b44a
6
+ metadata.gz: 66e216ce8dfc83b588d5fb20affb37daf38e9b54c203b2763d0b8218e5cefcf640261ca5a2d7e5c807e4a07cef8b1be1cbd7d99aaa1c7c7f1bd5076272b5c9ce
7
+ data.tar.gz: e13b11f4b9b6ffaa15e1f9da814d8bcef561054444cf06097133c50f32350ed57b66545d8395f8cd08943261b148717e8a36b7f4f98fb541289b2b8e83017609
data/README.md CHANGED
@@ -1,23 +1,62 @@
1
1
  # multipull
2
2
 
3
- Ruby implementation of multipull
3
+ [![Gem Version](https://badge.fury.io/rb/multipull.svg)](https://badge.fury.io/rb/multipull)
4
4
 
5
- ## installation
5
+ Ruby implementation of [multipull](https://dev.to/rmpato/git-pull-multiple-repositories-at-once-4l68).
6
+
7
+ ## Installation
6
8
 
7
9
  ```sh
8
10
  gem install multipull
9
11
  ```
10
12
 
13
+ ## Usage
14
+
15
+ ```sh
16
+ multipull
17
+ ```
18
+
19
+ ```sh
20
+ multipull ~/Ruby # directory
21
+ ```
22
+
11
23
  ## What is this?
12
24
 
13
- The original implementation is here.
25
+ The name of the command multipull was borrowed from the following article.
14
26
 
15
27
  [Git pull multiple repositories at once](https://dev.to/rmpato/git-pull-multiple-repositories-at-once-4l68) by [@rmpato](https://github.com/rmpato)
16
28
 
17
- ```
29
+ ```sh
18
30
  alias multipull="find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} pull \;"
19
31
  ```
20
32
 
33
+ The following pages include some great one-liners.
34
+
35
+ [Run git pull over all subdirectories](https://stackoverflow.com/questions/3497123/run-git-pull-over-all-subdirectories#12495234).
36
+
37
+ ```sh
38
+ find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
39
+ ```
40
+
41
+ ```sh
42
+ ls | xargs -I{} git -C {} pull
43
+ ls | xargs -P10 -I{} git -C {} pull
44
+ ```
45
+
46
+ ```sh
47
+ git config --global alias.all '!f() { ls -R -d */.git | xargs -I{} bash -c "echo {} && git -C {}/../ $1"; }; f'
48
+ ```
49
+
50
+ ```sh
51
+ for i in */.git; do ( echo $i; cd $i/..; git pull; ); done
52
+ ```
53
+
54
+ While these one-liners are nice, this multipull gem is better in the following ways
55
+
56
+ 1. No need to remember one-liners. `gem install multipull` is easier than writing alias in bashrc.
57
+ 2. No need to modify scripts for each OS.
58
+ 3. Options can be added as needed.
59
+
21
60
  ## Development
22
61
 
23
62
  PR welcome.
@@ -8,7 +8,8 @@ module Multipull
8
8
  include TerminalColor
9
9
 
10
10
  def initialize
11
- @dir = nil
11
+ # @options = {}
12
+ @dirs = []
12
13
  end
13
14
 
14
15
  def run
@@ -20,7 +21,7 @@ module Multipull
20
21
 
21
22
  def parse_options
22
23
  OptionParser.new do |opts|
23
- opts.banner = 'Usage: multipull [options] [dir]'
24
+ opts.banner = 'Usage: multipull [options] [dir...]'
24
25
 
25
26
  opts.on('-v', '--version', 'Show version') do
26
27
  puts VERSION
@@ -33,14 +34,28 @@ module Multipull
33
34
  end
34
35
  end.parse!
35
36
 
36
- @dir = ARGV.shift || '.'
37
+ @dirs = ARGV.empty? ? ['.'] : ARGV
37
38
  end
38
39
 
39
- def main
40
- Dir.chdir(@dir) do
41
- Dir.glob('*/').each do |dir|
42
- puts blue(bold(dir))
43
- system("git -C #{dir} pull")
40
+ def start_banner(dirs)
41
+ targets = blue(dirs.join(' '))
42
+ puts bold("multipull: #{targets}")
43
+ end
44
+
45
+ def main(dirs = @dirs)
46
+ start_banner(dirs)
47
+ dirs.each do |dir|
48
+ unless File.directory?(dir)
49
+ puts magenta("#{dir} is not a directory")
50
+ next
51
+ end
52
+ Dir.chdir(dir) do
53
+ Dir.glob('*/').each do |subdir|
54
+ puts blue(bold(subdir))
55
+ Dir.chdir(subdir) do
56
+ system('git pull')
57
+ end
58
+ end
44
59
  end
45
60
  end
46
61
  end
@@ -13,5 +13,13 @@ module Multipull
13
13
  def blue(s)
14
14
  "\e[34m#{s}\e[0m"
15
15
  end
16
+
17
+ def magenta(s)
18
+ "\033[35m#{s}\033[0m"
19
+ end
20
+
21
+ def red(s)
22
+ "\033[31m#{s}\033[0m"
23
+ end
16
24
  end
17
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Multipull
4
- VERSION = '0.0.0'
4
+ VERSION = '0.0.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multipull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2