git-multiple 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba6d4591141a79f0ca05e95426573574d2613510
4
+ data.tar.gz: eccd462ee221f338ca05a8d8150822792ff679a5
5
+ SHA512:
6
+ metadata.gz: 1c7710d3525dfab032f44a5348931140de187011ddef57aea4cb6c4add55a6667dca9c8745fb5dbc81e718ec0d018a2916a517559831079beb4adb9454dbc39a
7
+ data.tar.gz: b9789b67a30a37cd4947934b6c5b2d96743507d47a9783e5f74490721ff09d3452f2ab656c1850c0b4b3001c914471bf4d32716189e0ee165a55e6600ab3980a
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /sand-box
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ install: bundle install --path ./bundle
2
+ script: bundle exec rake spec
3
+ language: ruby
4
+ rvm:
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - jruby-19mode
8
+ - rbx-2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git-parallel.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Hiroshi IKEGAMI
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ <!--[![Build Status](https://travis-ci.org/magicdrive/ruby-git-multiple.svg?branch=feature%2Frspec)](https://travis-ci.org/magicdrive/ruby-git-multiple)-->
2
+
3
+ # Git::Parallel
4
+
5
+ Run the git command in parallel much to multiple git repositories.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'git-multiple'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install git-multiple
22
+
23
+ ## Usage
24
+
25
+
26
+ * `help`: show help
27
+
28
+ ```
29
+ $ git multiple help
30
+ ```
31
+
32
+ * `--exec|-e` (required): Define the command to be executed.
33
+
34
+ ```
35
+ $ git multiple --exec 'pull --rebase'
36
+ ```
37
+ * `--dirname|-d`: Specification of directories to search.(default `pwd`)
38
+
39
+ ```
40
+ $ git multiple --exec status --dirname /tmp
41
+ ```
42
+
43
+ * `--jobs|-j`: Number of jobs to be executed in parallel.
44
+
45
+ ```
46
+ $ git multiple --exec status --jobs 4
47
+ ```
48
+ * `--maxdepth|-m`: Deepest hierarchy of the directory to search. (default `1`)
49
+
50
+ ```
51
+ $ git multiple --exec status --maxdepth 10
52
+ ```
53
+
54
+ * `--no-color|-c`: is not carried out by coloring ANSI color.
55
+
56
+ ```
57
+ $ git multiple --exec status --no-color
58
+ ```
59
+
60
+ ####Of course, these options can be used in combination.
61
+
62
+ ```
63
+ $ git multiple --exec 'pull --rebase' \
64
+ --no-color \
65
+ --maxdepth 5 \
66
+ --jobs 8
67
+ ```
68
+
69
+ ####enjoy!
70
+
71
+ ## Contributing
72
+
73
+ 1. Fork it ( https://github.com/magicdrive/ruby-git-multiple/fork )
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # coding: utf-8
2
+ require "bundler/gem_tasks"
3
+ require "bundler/setup"
4
+
5
+ task :default => [:spec]
6
+
7
+ begin
8
+ require 'rspec/core/rake_task'
9
+ require 'rspec'
10
+ require 'rr'
11
+ RSpec::Core::RakeTask.new(:spec) do |t|
12
+ t.rspec_opts = ['-c', '-f progress', '-r ./spec/spec_helper.rb']
13
+ t.pattern = 'spec/**/*_spec.rb'
14
+ end
15
+ rescue LoadError => e
16
+ end
data/bin/git-multiple ADDED
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require File.expand_path('../lib/git/multiple', File.dirname(__FILE__))
5
+
6
+ Git::Multiple::CLI.start(ARGV)
7
+
8
+ __END__
9
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git/multiple/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git-multiple"
8
+ spec.version = Git::Multiple::VERSION
9
+ spec.authors = ["Hiroshi IKEGAMI"]
10
+ spec.email = ["hiroshi.ikegami@magicdrive.jp"]
11
+ spec.summary = %q{Run the git command in parallel much to multiple git repositories.}
12
+ spec.description = %q{Run the git command in parallel much to multiple git repositories.}
13
+ spec.homepage = "https://github.com/magicdrive/ruby-git-multiple"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'thor', '~> 0.19.1'
22
+ spec.add_runtime_dependency 'parallel', '~> 1.3.2'
23
+ spec.add_runtime_dependency 'highline', '~> 1.6.21'
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "pry"
28
+ end
@@ -0,0 +1,42 @@
1
+ # conding: utf-8
2
+
3
+ require 'thor'
4
+ require 'find'
5
+ require 'git/multiple/parallel_task'
6
+ require 'pry'
7
+
8
+ module Git
9
+ module Multiple
10
+ class CLI < Thor
11
+
12
+ public
13
+ desc "manupulate [OPTIONS]", "parallel manupulation for multiple repositories"
14
+ option :"no-color", aliases: "-c", type: :boolean
15
+ option :jobs, aliases: "-j", type: :numeric, default: 1
16
+ option :dirname, aliases: "-d", type: :numeric, default: Dir::pwd
17
+ option :maxdepth, default: 1
18
+ option :exec , required: true, aliases: "-e"
19
+ def manupulate
20
+ base_dir = options[:dirname]
21
+ git_command = options[:exec]
22
+ directories = find_dir(base_dir, options[:maxdepth])
23
+ Git::Multiple::PrallelTask.start(directories, git_command, options)
24
+ end
25
+
26
+ default_task :manupulate
27
+
28
+ private
29
+ def find_dir(base_dir, maxdepth)
30
+ result = []
31
+ Find.find(base_dir) do |f|
32
+ fname = File.expand_path(f)
33
+ Find.prune if fname.match %r<^#{base_dir}(?:/.*){#{maxdepth.to_i + 2}}>
34
+ Find.prune if File.exists?("#{File.dirname(fname)}/.git-parallel-skip")
35
+ result.push(File.dirname(fname)) if File.basename(fname) == ".git"
36
+ end
37
+ return result
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,59 @@
1
+ # conding: utf-8
2
+
3
+ require 'systemu'
4
+ require 'stringio'
5
+ require 'parallel'
6
+ require 'highline'
7
+
8
+ module Git
9
+ module Multiple
10
+ module PrallelTask
11
+
12
+ class << self
13
+ public
14
+ def start(directories, command, options)
15
+ git_command = build_git_cmd(command, options)
16
+
17
+ func = block_given? ? Proc.new(&block) : proc {true}
18
+
19
+ h = HighLine.new
20
+ Parallel.each(directories, in_threads: options[:jobs]) do |dirname|
21
+
22
+ Dir::chdir(dirname)
23
+ disp_dirname = dirname[%r{^#{options[:dirname]}/(.*)$}xo, 1]
24
+ disp_dirname = options[:dirname] if dirname == options[:dirname]
25
+ result = ""
26
+
27
+ if options[:"no-color"]
28
+ result << "result git #{command} ::: #{disp_dirname}" << "\n"
29
+ else
30
+ result << "#{h.color("result", :black,:on_green)} " <<
31
+ "#{h.color("git #{command}", :magenta)} " <<
32
+ "::: " <<
33
+ "#{h.color(disp_dirname, :yellow)}" <<
34
+ "\n"
35
+ end
36
+
37
+ result << %x{#{git_command} 2>&1}
38
+ result << "\n"
39
+ next unless func.call(dirname, result)
40
+
41
+ puts result
42
+ end
43
+ end
44
+
45
+ private
46
+ def build_git_cmd(sub_command, options)
47
+ color_opt = case options[:"no-color"]
48
+ when true then 'false'
49
+ else 'always'
50
+ end
51
+
52
+ return "git -c color.ui=#{color_opt} #{sub_command}"
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Git
2
+ module Multiple
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "git/multiple/version"
2
+ require "git/multiple/cli"
3
+ require "git/multiple/parallel_task"
4
+
5
+ module Git
6
+ module Multiple
7
+ #configure
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+
3
+ describe Git::Multiple::CLI do
4
+
5
+ context 'success' do
6
+
7
+
8
+ end
9
+
10
+
11
+ end
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ __END__
@@ -0,0 +1,20 @@
1
+ # spec_helper file.
2
+ require File.expand_path('../lib/git/multiple', File.dirname(__FILE__))
3
+ require 'stringio'
4
+ require 'pry'
5
+
6
+ def capture(stream)
7
+ begin
8
+ stream = stream.to_s
9
+ eval "$#{stream} = StringIO.new"
10
+ yield
11
+ result = eval("$#{stream}").string
12
+ ensure
13
+ eval("$#{stream} = #{stream.upcase}")
14
+ end
15
+ return result
16
+ end
17
+
18
+ PROJECT_ROOT = "#{File.expand_path("../", File.dirname(__FILE__))}"
19
+
20
+ __END__
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-multiple
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroshi IKEGAMI
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: parallel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.21
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.21
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Run the git command in parallel much to multiple git repositories.
112
+ email:
113
+ - hiroshi.ikegami@magicdrive.jp
114
+ executables:
115
+ - git-multiple
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/git-multiple
126
+ - git-multiple.gemspec
127
+ - lib/git/multiple.rb
128
+ - lib/git/multiple/cli.rb
129
+ - lib/git/multiple/parallel_task.rb
130
+ - lib/git/multiple/version.rb
131
+ - spec/lib/git/multiple/cli_spec.rb
132
+ - spec/spec_helper.rb
133
+ homepage: https://github.com/magicdrive/ruby-git-multiple
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.2.2
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Run the git command in parallel much to multiple git repositories.
157
+ test_files:
158
+ - spec/lib/git/multiple/cli_spec.rb
159
+ - spec/spec_helper.rb