guitr 0.0.4
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.
- data/History.txt +24 -0
- data/MIT-LICENSE +22 -0
- data/Manifest.txt +18 -0
- data/README.rdoc +58 -0
- data/Rakefile +38 -0
- data/bin/guitr +17 -0
- data/lib/guitr.rb +9 -0
- data/lib/guitr/exceptions.rb +14 -0
- data/lib/guitr/git.rb +95 -0
- data/lib/guitr/guitr.rb +92 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/git_spec.rb +133 -0
- data/spec/guitr_spec.rb +78 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/rspec.rake +21 -0
- metadata +152 -0
data/History.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
=== 0.0.1 2010-06-10
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
* Initial release
|
5
|
+
|
6
|
+
=== 0.0.2 2010-06-11
|
7
|
+
|
8
|
+
* 2 major enhancements:
|
9
|
+
* Own git status command implementation was added
|
10
|
+
* Logging now can be specified with --verbose or --trace
|
11
|
+
* Specs for most operations were added
|
12
|
+
|
13
|
+
=== 0.0.3 2010-06-12
|
14
|
+
|
15
|
+
* 1 major enhancement:
|
16
|
+
* --unpushed argument was added to check whether there are commits need to be pushed
|
17
|
+
|
18
|
+
=== 0.0.4 2010-06-17
|
19
|
+
|
20
|
+
* 2 major enhancements:
|
21
|
+
* --pull operation was refactored
|
22
|
+
* bug with absence of the remote branch or empty repo was fixed
|
23
|
+
Other
|
24
|
+
* additional small improvements
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2008,2009 Jake Scruggs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
History.txt
|
2
|
+
MIT-LICENSE
|
3
|
+
Manifest.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
bin/guitr
|
7
|
+
lib/guitr.rb
|
8
|
+
lib/guitr/exceptions.rb
|
9
|
+
lib/guitr/git.rb
|
10
|
+
lib/guitr/guitr.rb
|
11
|
+
script/console
|
12
|
+
script/destroy
|
13
|
+
script/generate
|
14
|
+
spec/git_spec.rb
|
15
|
+
spec/guitr_spec.rb
|
16
|
+
spec/spec.opts
|
17
|
+
spec/spec_helper.rb
|
18
|
+
tasks/rspec.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= guitr
|
2
|
+
|
3
|
+
* http://webdizz.name/posts/guitr
|
4
|
+
* http://github.com/webdizz/guitr
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
The gem to ease of some git actions on multi-modules project with separate repository per module.
|
9
|
+
Can be used to check status or existence of commits within modules not pushed yet, also to pull all repositories at once.
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
Can pull all git working directories from given path.
|
14
|
+
Lets ensure that everything is under git control that should be.
|
15
|
+
|
16
|
+
== SYNOPSIS:
|
17
|
+
|
18
|
+
guitr [options] [path_to_repo if not specified current directory will be used]
|
19
|
+
|
20
|
+
Options:
|
21
|
+
--status # default command to invoke, echos result of the 'git status'
|
22
|
+
--pull # performs 'git pull' against all found repositories
|
23
|
+
--unpushed # checks whether there are commits need to be pushed
|
24
|
+
--verbose # echos INFO level logs
|
25
|
+
--trace # echos DEBUG level logs
|
26
|
+
|
27
|
+
== REQUIREMENTS:
|
28
|
+
|
29
|
+
Gems: git
|
30
|
+
|
31
|
+
== INSTALL:
|
32
|
+
|
33
|
+
sudo gem install guitr
|
34
|
+
|
35
|
+
== LICENSE:
|
36
|
+
|
37
|
+
(The MIT License)
|
38
|
+
|
39
|
+
Copyright (c) 2010 Izzet Mustafa oglu
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
a copy of this software and associated documentation files (the
|
43
|
+
'Software'), to deal in the Software without restriction, including
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be
|
50
|
+
included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
gem 'git', '>=1.2.5'
|
4
|
+
|
5
|
+
require 'hoe'
|
6
|
+
require 'git'
|
7
|
+
require 'fileutils'
|
8
|
+
require './lib/guitr'
|
9
|
+
|
10
|
+
Hoe.plugin :newgem
|
11
|
+
Hoe.plugin :git
|
12
|
+
|
13
|
+
# Generate all the Rake tasks
|
14
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
15
|
+
$hoe = Hoe.spec 'guitr' do
|
16
|
+
self.developer 'webdizz', 'webdizz@gmail.com'
|
17
|
+
self.post_install_message = "
|
18
|
+
Usage:
|
19
|
+
guitr [options] [path_to_repo if not specified current directory will be used]
|
20
|
+
|
21
|
+
Options:
|
22
|
+
--status # default command to invoke, echos result of the 'git status'
|
23
|
+
--pull # performs 'git pull' against all found repositories
|
24
|
+
--unpushed # checks whether there are commits need to be pushed
|
25
|
+
--verbose # echos INFO level logs
|
26
|
+
--trace # echos DEBUG level logs
|
27
|
+
|
28
|
+
For details go to http://webdizz.name/posts/guitr
|
29
|
+
"
|
30
|
+
self.rubyforge_name = self.name # TODO this is default value
|
31
|
+
self.extra_deps = [
|
32
|
+
['git','>= 1.2.5'],
|
33
|
+
['hoe', ">= #{Hoe::VERSION}"]
|
34
|
+
]
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'newgem/tasks'
|
data/bin/guitr
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
4
|
+
require 'guitr'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
puts "#{File.basename($0)} #{Guitr::VERSION}"
|
8
|
+
exit(0)
|
9
|
+
end
|
10
|
+
|
11
|
+
args = ARGV.clone
|
12
|
+
|
13
|
+
begin
|
14
|
+
Guitr::GuitrRunner.new.run args
|
15
|
+
rescue Guitr::SystemExitException => e
|
16
|
+
exit e.exit_code
|
17
|
+
end
|
data/lib/guitr.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
##
|
2
|
+
# Raised to indicate that a system exit should occur with the specified
|
3
|
+
# exit_code
|
4
|
+
|
5
|
+
class Guitr::SystemExitException < SystemExit
|
6
|
+
attr_accessor :exit_code
|
7
|
+
|
8
|
+
def initialize(exit_code)
|
9
|
+
@exit_code = exit_code
|
10
|
+
|
11
|
+
super "Exiting Guitr with exit_code #{exit_code}"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/lib/guitr/git.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
module Guitr
|
5
|
+
module GuitrGit
|
6
|
+
|
7
|
+
class GitStatus
|
8
|
+
|
9
|
+
attr_reader :git
|
10
|
+
|
11
|
+
def run(repo, options = {})
|
12
|
+
@git = Git.open(repo, options)
|
13
|
+
res = @git.lib.status
|
14
|
+
puts
|
15
|
+
puts "Status for #{repo}"
|
16
|
+
puts res = res.gsub('??', ' U')
|
17
|
+
puts
|
18
|
+
|
19
|
+
res
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class GitUnpushed
|
25
|
+
|
26
|
+
attr_reader :git
|
27
|
+
|
28
|
+
def run(repo, options={})
|
29
|
+
@git = Git.open(repo, options)
|
30
|
+
git_lib = @git.lib
|
31
|
+
current_branch = git_lib.branch_current
|
32
|
+
remote = git_lib.remotes
|
33
|
+
if remote.empty?
|
34
|
+
puts "There is no remote for '#{repo}' repository."
|
35
|
+
return ''
|
36
|
+
end
|
37
|
+
res = ''
|
38
|
+
begin
|
39
|
+
res = git_lib.unpushed(current_branch, "#{remote}/#{current_branch}")
|
40
|
+
if !res.empty?
|
41
|
+
puts
|
42
|
+
puts 'Unpushed commits: '
|
43
|
+
puts res
|
44
|
+
puts
|
45
|
+
end
|
46
|
+
puts "There is no unpushed commits for #{repo} repository." if res.empty?
|
47
|
+
rescue Git::GitExecuteError => e
|
48
|
+
puts "Unable to check unpushed commits: #{e.message}"
|
49
|
+
end
|
50
|
+
|
51
|
+
res
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
class GitPull
|
57
|
+
|
58
|
+
attr_reader :git
|
59
|
+
|
60
|
+
def run(repo, options = {})
|
61
|
+
@git = Git.open(repo, options)
|
62
|
+
begin
|
63
|
+
puts
|
64
|
+
puts "Going to pull #{repo}"
|
65
|
+
res = @git.lib.pull
|
66
|
+
puts res
|
67
|
+
res
|
68
|
+
rescue Git::GitExecuteError => e
|
69
|
+
puts "Unable to pull: #{e.message}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
module Git
|
79
|
+
|
80
|
+
class Lib
|
81
|
+
|
82
|
+
def status
|
83
|
+
command('status', ['--porcelain'])
|
84
|
+
end
|
85
|
+
|
86
|
+
def unpushed branch, remote_branch
|
87
|
+
command('diff', ['--numstat', '--shortstat', branch, remote_branch])
|
88
|
+
end
|
89
|
+
|
90
|
+
def pull
|
91
|
+
command('pull')
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
data/lib/guitr/guitr.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'git'
|
3
|
+
require 'find'
|
4
|
+
require 'logger'
|
5
|
+
require 'guitr/git'
|
6
|
+
|
7
|
+
module Guitr
|
8
|
+
|
9
|
+
class GuitrRunner
|
10
|
+
|
11
|
+
include GuitrGit
|
12
|
+
|
13
|
+
attr_reader :repo_paths, :operation, :log
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@operational_args = ['--status', '--pull', '--unpushed']
|
17
|
+
@acceptable_args = [:verbose, :trace] << @operational_args
|
18
|
+
@acceptable_args = @acceptable_args.flatten
|
19
|
+
@repo_paths = []
|
20
|
+
@git_dir = '.git'
|
21
|
+
@usage = '$ guitr --status|--pull path_to_git_repo(s) '
|
22
|
+
@options = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def run(args)
|
26
|
+
validate args
|
27
|
+
res = ''
|
28
|
+
@repo_paths.flatten.uniq.each do |repo|
|
29
|
+
case @operation.to_sym
|
30
|
+
when :pull
|
31
|
+
res = GitPull.new.run(repo, @options)
|
32
|
+
when :status
|
33
|
+
res = GitStatus.new.run(repo, @options)
|
34
|
+
when :unpushed
|
35
|
+
res = GitUnpushed.new.run(repo, @options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
res
|
39
|
+
end
|
40
|
+
|
41
|
+
def validate(args)
|
42
|
+
init_logger(args)
|
43
|
+
|
44
|
+
args.each do |arg|
|
45
|
+
@operation = arg.gsub('--', '') if @operational_args.include?(arg) && @operation.nil?
|
46
|
+
end
|
47
|
+
@operation = :status if @operation.nil?
|
48
|
+
|
49
|
+
start_directory = './'
|
50
|
+
last = args.last
|
51
|
+
if last.nil? || last.include?('--')
|
52
|
+
@log.info 'Current directory will be used to start looking for git working copies.' if @log
|
53
|
+
else
|
54
|
+
start_directory = args.last
|
55
|
+
end
|
56
|
+
|
57
|
+
if !File.exist? start_directory
|
58
|
+
puts "Directory '#{start_directory}' does not exist."
|
59
|
+
exit()
|
60
|
+
end
|
61
|
+
|
62
|
+
Find.find(start_directory) do |path|
|
63
|
+
if path.include?(@git_dir) && !path.include?("#{@git_dir}/") && File.exist?(path) && File.directory?(path)
|
64
|
+
@repo_paths << File.expand_path(path.gsub(@git_dir, ''))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
if @repo_paths.empty?
|
69
|
+
puts "There are no repositories within '#{start_directory}' directory."
|
70
|
+
exit()
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def init_logger args
|
76
|
+
args.each do |arg|
|
77
|
+
arg = arg.gsub('--', '')
|
78
|
+
create_logger(Logger::INFO) if arg.to_sym == :verbose
|
79
|
+
create_logger(Logger::DEBUG) if arg.to_sym == :trace
|
80
|
+
end
|
81
|
+
end
|
82
|
+
private :init_logger
|
83
|
+
|
84
|
+
def create_logger level
|
85
|
+
@log = Logger.new STDOUT
|
86
|
+
@log.level = level
|
87
|
+
@options[:log] = @log
|
88
|
+
end
|
89
|
+
private :create_logger
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/guitr.rb'}"
|
9
|
+
puts "Loading guitr gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/git_spec.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
include Guitr::GuitrGit
|
5
|
+
|
6
|
+
describe Guitr::GuitrGit do
|
7
|
+
|
8
|
+
$RIGHT_REPO = File.expand_path(File.dirname(__FILE__)+'/../')
|
9
|
+
|
10
|
+
describe GitStatus do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@test_file_name = 'some_file'
|
14
|
+
@action = GitStatus.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have a git instance if right repo was passed" do
|
18
|
+
@action.run $RIGHT_REPO, {}
|
19
|
+
@action.git.should_not be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should show untracked files" do
|
23
|
+
begin
|
24
|
+
file = open(@test_file_name, "w")
|
25
|
+
res = @action.run $RIGHT_REPO, {}
|
26
|
+
res.should include @test_file_name
|
27
|
+
ensure
|
28
|
+
clean_test_file(file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should mark untracked files with U letter" do
|
33
|
+
begin
|
34
|
+
file = open(@test_file_name, "w")
|
35
|
+
res = @action.run $RIGHT_REPO, {}
|
36
|
+
res.should_not include '??'
|
37
|
+
res.should include 'U'
|
38
|
+
ensure
|
39
|
+
clean_test_file(file)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def clean_test_file file
|
44
|
+
file.close
|
45
|
+
File.delete @test_file_name
|
46
|
+
end
|
47
|
+
private :clean_test_file
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe GitUnpushed do
|
52
|
+
|
53
|
+
before do
|
54
|
+
@action = GitUnpushed.new
|
55
|
+
@test_file_name = 'some_file_2'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have a git instance if repo path is correct" do
|
59
|
+
@action.run $RIGHT_REPO, {}
|
60
|
+
@action.git.should_not be_nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should display unpushed items" do
|
64
|
+
module Git
|
65
|
+
class Lib
|
66
|
+
def unpushed branch, remote_branch
|
67
|
+
'insertions'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
res = @action.run $RIGHT_REPO, {}
|
72
|
+
res.should include('insertions')
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should report an error without interruption if error was occured on unpushed action" do
|
76
|
+
lambda{
|
77
|
+
module Git
|
78
|
+
class Lib
|
79
|
+
def unpushed branch, remote_branch
|
80
|
+
raise Git::GitExecuteError.new("Something was wrong")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
@action.run $RIGHT_REPO, {}
|
85
|
+
}.should_not raise_exception Git::GitExecuteError
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
describe GitPull do
|
91
|
+
|
92
|
+
before do
|
93
|
+
@action = GitPull.new
|
94
|
+
@test_file_name = 'some_file_2'
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should have a git instance if repo path is correct" do
|
98
|
+
@action.run $RIGHT_REPO, {}
|
99
|
+
@action.git.should_not be_nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should display unpushed items or display nothing" do
|
103
|
+
res = @action.run $RIGHT_REPO, {}
|
104
|
+
res.should include('Updating')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should report an error without interruption if error was occured on pull action" do
|
108
|
+
lambda{
|
109
|
+
module Git
|
110
|
+
class Lib
|
111
|
+
def pull
|
112
|
+
raise Git::GitExecuteError.new("Something was wrong")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
@action.run $RIGHT_REPO, {}
|
117
|
+
}.should_not raise_exception Git::GitExecuteError
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
module Git
|
125
|
+
|
126
|
+
class Lib
|
127
|
+
|
128
|
+
def pull
|
129
|
+
'Updating'
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
data/spec/guitr_spec.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
describe Guitr::GuitrRunner do
|
5
|
+
|
6
|
+
$CURRENT_DIR_PATH = File.expand_path(File.dirname(__FILE__))
|
7
|
+
$RIGHT_REPO_PATH = File.expand_path(File.dirname(__FILE__)+'/../')
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@guitr_runner = Guitr::GuitrRunner.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should continue if no args were specified" do
|
14
|
+
args = [];
|
15
|
+
@guitr_runner.validate args
|
16
|
+
@guitr_runner.operation.should eql(:status)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should use current directory if no path specified" do
|
20
|
+
args = [];
|
21
|
+
@guitr_runner.validate args
|
22
|
+
@guitr_runner.repo_paths.size.should eql(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should fail if specified directory does not exist" do
|
26
|
+
args = ['some_path'];
|
27
|
+
lambda { @guitr_runner.validate(args)}.should raise_exception SystemExit
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should use specified directory if exist" do
|
31
|
+
args = [$RIGHT_REPO_PATH];
|
32
|
+
lambda { @guitr_runner.validate(args)}.should_not raise_exception SystemExit
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should fail if there is are no repositories within specified directory" do
|
36
|
+
args = [$CURRENT_DIR_PATH];
|
37
|
+
lambda { @guitr_runner.validate(args)}.should raise_exception SystemExit
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should operate verbosely if --verbose was specified" do
|
41
|
+
args = ['--verbose', $RIGHT_REPO_PATH]
|
42
|
+
@guitr_runner.validate args
|
43
|
+
@guitr_runner.log.should_not be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should use INFO logger if --verbose was specified" do
|
47
|
+
args = ['--verbose', $RIGHT_REPO_PATH]
|
48
|
+
@guitr_runner.validate args
|
49
|
+
@guitr_runner.log.level.should eql(Logger::INFO)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should operate in debug mode if --trace was specified" do
|
53
|
+
args = ['--trace', $RIGHT_REPO_PATH]
|
54
|
+
@guitr_runner.validate args
|
55
|
+
@guitr_runner.log.level.should eql(Logger::DEBUG)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should use first operation argument to operate with" do
|
59
|
+
args = ['--trace', '--status', '--pull', $RIGHT_REPO_PATH]
|
60
|
+
@guitr_runner.validate args
|
61
|
+
@guitr_runner.operation.should eql(:status.to_s)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have unpushed operation" do
|
65
|
+
args = ['--unpushed'];
|
66
|
+
@guitr_runner.validate args
|
67
|
+
@guitr_runner.operation.should eql(:unpushed.to_s)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should have empty or some satistic of unpushed changes" do
|
71
|
+
args = ['--unpushed', $RIGHT_REPO_PATH];
|
72
|
+
res = @guitr_runner.run args
|
73
|
+
res.should be_empty if res.empty?
|
74
|
+
res.should include('insertions') if !res.empty?
|
75
|
+
res.should_not include('nothing to do')
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
gem 'rspec'
|
6
|
+
gem 'git'
|
7
|
+
require 'spec'
|
8
|
+
require 'git'
|
9
|
+
end
|
10
|
+
|
11
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
12
|
+
|
13
|
+
require 'guitr'
|
14
|
+
require 'guitr/guitr'
|
15
|
+
require 'guitr/git'
|
16
|
+
require 'guitr/exceptions'
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guitr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- webdizz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-17 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: git
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 5
|
34
|
+
version: 1.2.5
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hoe
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 6
|
49
|
+
- 0
|
50
|
+
version: 2.6.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rubyforge
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 7
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 0
|
65
|
+
- 4
|
66
|
+
version: 2.0.4
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: hoe
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 23
|
78
|
+
segments:
|
79
|
+
- 2
|
80
|
+
- 6
|
81
|
+
- 0
|
82
|
+
version: 2.6.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
description: |-
|
86
|
+
The gem to ease of some git actions on multi-modules project with separate repository per module.
|
87
|
+
Can be used to check status or existence of commits within modules not pushed yet, also to pull all repositories at once.
|
88
|
+
email:
|
89
|
+
- webdizz@gmail.com
|
90
|
+
executables:
|
91
|
+
- guitr
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files:
|
95
|
+
- History.txt
|
96
|
+
- Manifest.txt
|
97
|
+
files:
|
98
|
+
- History.txt
|
99
|
+
- MIT-LICENSE
|
100
|
+
- Manifest.txt
|
101
|
+
- README.rdoc
|
102
|
+
- Rakefile
|
103
|
+
- bin/guitr
|
104
|
+
- lib/guitr.rb
|
105
|
+
- lib/guitr/exceptions.rb
|
106
|
+
- lib/guitr/git.rb
|
107
|
+
- lib/guitr/guitr.rb
|
108
|
+
- script/console
|
109
|
+
- script/destroy
|
110
|
+
- script/generate
|
111
|
+
- spec/git_spec.rb
|
112
|
+
- spec/guitr_spec.rb
|
113
|
+
- spec/spec.opts
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- tasks/rspec.rake
|
116
|
+
has_rdoc: true
|
117
|
+
homepage: http://webdizz.name/posts/guitr
|
118
|
+
licenses: []
|
119
|
+
|
120
|
+
post_install_message: "\n Usage: \n guitr [options] [path_to_repo if not specified current directory will be used]\n \n Options:\n --status # default command to invoke, echos result of the 'git status'\n --pull # performs 'git pull' against all found repositories\n --unpushed # checks whether there are commits need to be pushed\n --verbose # echos INFO level logs\n --trace # echos DEBUG level logs\n \n For details go to http://webdizz.name/posts/guitr\n "
|
121
|
+
rdoc_options:
|
122
|
+
- --main
|
123
|
+
- README.rdoc
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
requirements: []
|
145
|
+
|
146
|
+
rubyforge_project: guitr
|
147
|
+
rubygems_version: 1.3.7
|
148
|
+
signing_key:
|
149
|
+
specification_version: 3
|
150
|
+
summary: The gem to ease of some git actions on multi-modules project with separate repository per module
|
151
|
+
test_files: []
|
152
|
+
|