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 +4 -4
- data/README.md +43 -4
- data/lib/multipull/command.rb +23 -8
- data/lib/multipull/terminal_color.rb +8 -0
- data/lib/multipull/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f1d52ce7937a9cbdf187fb67e70da3d855674c967f2d933a236d7ae11260f53
|
4
|
+
data.tar.gz: 3d852fa553f4fbfaa5777ce0a05edbfa4a43361023b5b6357f43f1cb2e603904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66e216ce8dfc83b588d5fb20affb37daf38e9b54c203b2763d0b8218e5cefcf640261ca5a2d7e5c807e4a07cef8b1be1cbd7d99aaa1c7c7f1bd5076272b5c9ce
|
7
|
+
data.tar.gz: e13b11f4b9b6ffaa15e1f9da814d8bcef561054444cf06097133c50f32350ed57b66545d8395f8cd08943261b148717e8a36b7f4f98fb541289b2b8e83017609
|
data/README.md
CHANGED
@@ -1,23 +1,62 @@
|
|
1
1
|
# multipull
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/multipull.svg)](https://badge.fury.io/rb/multipull)
|
4
4
|
|
5
|
-
|
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
|
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.
|
data/lib/multipull/command.rb
CHANGED
@@ -8,7 +8,8 @@ module Multipull
|
|
8
8
|
include TerminalColor
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
@
|
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
|
-
@
|
37
|
+
@dirs = ARGV.empty? ? ['.'] : ARGV
|
37
38
|
end
|
38
39
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
data/lib/multipull/version.rb
CHANGED