brigit 0.8.2 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +17 -0
- data/README.rdoc +9 -0
- data/Rakefile +2 -2
- data/bin/brigit +1 -3
- data/brigit.gemspec +125 -49
- data/help/grab.rdoc +16 -0
- data/help/hop.rdoc +36 -0
- data/help/map.rdoc +19 -0
- data/help/update.rdoc +9 -0
- data/lib/brigit/cli.rb +12 -43
- data/lib/brigit/commands/command.rb +43 -7
- data/lib/brigit/commands/grab_command.rb +23 -23
- data/lib/brigit/commands/hop_command.rb +91 -0
- data/lib/brigit/commands/map_command.rb +12 -9
- data/lib/brigit/commands/update_command.rb +4 -6
- data/lib/brigit/fallible.rb +1 -1
- data/lib/brigit/inventories/gitosis_inventory.rb +1 -1
- data/lib/brigit/listable.rb +1 -1
- data/lib/brigit/pretending.rb +25 -0
- data/lib/brigit/version.rb +2 -2
- data/lib/brigit.rb +33 -2
- data/test/brigit_test.rb +70 -0
- data/test/cli_test.rb +47 -0
- data/test/command_test.rb +47 -0
- data/test/fallible_test.rb +33 -0
- data/test/fixtures/gitosis-admin/gitosis.conf +16 -0
- data/test/fixtures/grab_command/existing_directory/stub +1 -0
- data/test/fixtures/submodule_methods/parent/submodule/foo.rb +1 -0
- data/test/gitosis_test.rb +40 -0
- data/test/grab_command_test.rb +55 -0
- data/test/inventory_test.rb +22 -0
- data/test/option_parser_test.rb +21 -0
- data/test/test_helper.rb +32 -1
- metadata +42 -6
data/Manifest
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
bin/brigit
|
2
|
+
help/grab.rdoc
|
3
|
+
help/hop.rdoc
|
4
|
+
help/map.rdoc
|
5
|
+
help/update.rdoc
|
2
6
|
lib/brigit/cli.rb
|
3
7
|
lib/brigit/commands/command.rb
|
4
8
|
lib/brigit/commands/grab_command.rb
|
9
|
+
lib/brigit/commands/hop_command.rb
|
5
10
|
lib/brigit/commands/map_command.rb
|
6
11
|
lib/brigit/commands/update_command.rb
|
7
12
|
lib/brigit/config_parser.rb
|
@@ -9,12 +14,24 @@ lib/brigit/fallible.rb
|
|
9
14
|
lib/brigit/inventories/gitosis_inventory.rb
|
10
15
|
lib/brigit/inventories/inventory.rb
|
11
16
|
lib/brigit/listable.rb
|
17
|
+
lib/brigit/pretending.rb
|
12
18
|
lib/brigit/version.rb
|
13
19
|
lib/brigit.rb
|
14
20
|
lib/ext/option_parser.rb
|
15
21
|
Manifest
|
16
22
|
Rakefile
|
17
23
|
README.rdoc
|
24
|
+
test/brigit_test.rb
|
25
|
+
test/cli_test.rb
|
26
|
+
test/command_test.rb
|
18
27
|
test/config_parser_test.rb
|
28
|
+
test/fallible_test.rb
|
19
29
|
test/fixtures/example.conf
|
30
|
+
test/fixtures/gitosis-admin/gitosis.conf
|
31
|
+
test/fixtures/grab_command/existing_directory/stub
|
32
|
+
test/fixtures/submodule_methods/parent/submodule/foo.rb
|
33
|
+
test/gitosis_test.rb
|
34
|
+
test/grab_command_test.rb
|
35
|
+
test/inventory_test.rb
|
36
|
+
test/option_parser_test.rb
|
20
37
|
test/test_helper.rb
|
data/README.rdoc
CHANGED
@@ -6,6 +6,15 @@ A random collection of utilities for developers working with Git repositories.
|
|
6
6
|
|
7
7
|
Feel free to fork, send patches, etc. Development is done at http://github.com/fiveruns/brigit
|
8
8
|
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
Call the +brigit+ executable without any arguments to get the list of commands;
|
12
|
+
you can then do:
|
13
|
+
|
14
|
+
brigit <command> --help
|
15
|
+
|
16
|
+
The same information is available under the help/.
|
17
|
+
|
9
18
|
== Authors
|
10
19
|
|
11
20
|
The FiveRuns development team, http://www.fiveruns.org
|
data/Rakefile
CHANGED
data/bin/brigit
CHANGED
data/brigit.gemspec
CHANGED
@@ -1,55 +1,131 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Brigit-0.
|
2
|
+
# Gem::Specification for Brigit-0.9.1
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
|
-
Gem::Specification
|
6
|
-
|
7
|
-
|
5
|
+
--- !ruby/object:Gem::Specification
|
6
|
+
name: brigit
|
7
|
+
version: !ruby/object:Gem::Version
|
8
|
+
version: 0.9.1
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- FiveRuns Development Team
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
date: 2008-07-12 00:00:00 -05:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: echoe
|
20
|
+
type: :development
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: "0"
|
27
|
+
version:
|
28
|
+
description: Git utilities
|
29
|
+
email: dev@fiveruns.com
|
30
|
+
executables:
|
31
|
+
- brigit
|
32
|
+
extensions: []
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
extra_rdoc_files:
|
35
|
+
- bin/brigit
|
36
|
+
- lib/brigit/cli.rb
|
37
|
+
- lib/brigit/commands/command.rb
|
38
|
+
- lib/brigit/commands/grab_command.rb
|
39
|
+
- lib/brigit/commands/hop_command.rb
|
40
|
+
- lib/brigit/commands/map_command.rb
|
41
|
+
- lib/brigit/commands/update_command.rb
|
42
|
+
- lib/brigit/config_parser.rb
|
43
|
+
- lib/brigit/fallible.rb
|
44
|
+
- lib/brigit/inventories/gitosis_inventory.rb
|
45
|
+
- lib/brigit/inventories/inventory.rb
|
46
|
+
- lib/brigit/listable.rb
|
47
|
+
- lib/brigit/pretending.rb
|
48
|
+
- lib/brigit/version.rb
|
49
|
+
- lib/brigit.rb
|
50
|
+
- lib/ext/option_parser.rb
|
51
|
+
- README.rdoc
|
52
|
+
files:
|
53
|
+
- bin/brigit
|
54
|
+
- help/grab.rdoc
|
55
|
+
- help/hop.rdoc
|
56
|
+
- help/map.rdoc
|
57
|
+
- help/update.rdoc
|
58
|
+
- lib/brigit/cli.rb
|
59
|
+
- lib/brigit/commands/command.rb
|
60
|
+
- lib/brigit/commands/grab_command.rb
|
61
|
+
- lib/brigit/commands/hop_command.rb
|
62
|
+
- lib/brigit/commands/map_command.rb
|
63
|
+
- lib/brigit/commands/update_command.rb
|
64
|
+
- lib/brigit/config_parser.rb
|
65
|
+
- lib/brigit/fallible.rb
|
66
|
+
- lib/brigit/inventories/gitosis_inventory.rb
|
67
|
+
- lib/brigit/inventories/inventory.rb
|
68
|
+
- lib/brigit/listable.rb
|
69
|
+
- lib/brigit/pretending.rb
|
70
|
+
- lib/brigit/version.rb
|
71
|
+
- lib/brigit.rb
|
72
|
+
- lib/ext/option_parser.rb
|
73
|
+
- Manifest
|
74
|
+
- Rakefile
|
75
|
+
- README.rdoc
|
76
|
+
- test/brigit_test.rb
|
77
|
+
- test/cli_test.rb
|
78
|
+
- test/command_test.rb
|
79
|
+
- test/config_parser_test.rb
|
80
|
+
- test/fallible_test.rb
|
81
|
+
- test/fixtures/example.conf
|
82
|
+
- test/fixtures/gitosis-admin/gitosis.conf
|
83
|
+
- test/fixtures/grab_command/existing_directory/stub
|
84
|
+
- test/fixtures/submodule_methods/parent/submodule/foo.rb
|
85
|
+
- test/gitosis_test.rb
|
86
|
+
- test/grab_command_test.rb
|
87
|
+
- test/inventory_test.rb
|
88
|
+
- test/option_parser_test.rb
|
89
|
+
- test/test_helper.rb
|
90
|
+
- brigit.gemspec
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://github.com/fiveruns/brigit
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options:
|
95
|
+
- --line-numbers
|
96
|
+
- --inline-source
|
97
|
+
- --title
|
98
|
+
- Brigit
|
99
|
+
- --main
|
100
|
+
- README.rdoc
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
108
|
+
version:
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: "1.2"
|
114
|
+
version:
|
115
|
+
requirements: []
|
30
116
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# Echoe.new 'brigit' do |p|
|
47
|
-
# p.version = Brigit::Version::STRING
|
48
|
-
# p.author = "FiveRuns Development Team"
|
49
|
-
# p.email = 'dev@fiveruns.com'
|
50
|
-
# p.project = 'fiveruns'
|
51
|
-
# p.summary = "Git utilities"
|
52
|
-
# p.url = "http://github.com/fiveruns/brigit"
|
53
|
-
# p.include_rakefile = true
|
54
|
-
# end
|
55
|
-
#
|
117
|
+
rubyforge_project: fiveruns
|
118
|
+
rubygems_version: 1.2.0
|
119
|
+
specification_version: 2
|
120
|
+
summary: Git utilities
|
121
|
+
test_files:
|
122
|
+
- test/brigit_test.rb
|
123
|
+
- test/cli_test.rb
|
124
|
+
- test/command_test.rb
|
125
|
+
- test/config_parser_test.rb
|
126
|
+
- test/fallible_test.rb
|
127
|
+
- test/gitosis_test.rb
|
128
|
+
- test/grab_command_test.rb
|
129
|
+
- test/inventory_test.rb
|
130
|
+
- test/option_parser_test.rb
|
131
|
+
- test/test_helper.rb
|
data/help/grab.rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Grab repos matching optional pattern from a gitosis-admin config"
|
2
|
+
|
3
|
+
== Syntax
|
4
|
+
|
5
|
+
brigit grab PATH_TO_GITOSIS_ADMIN_REPO [PATTERN, ...]
|
6
|
+
|
7
|
+
== Examples
|
8
|
+
|
9
|
+
Using the list of repositories provided by ~/gitosis-admin, clone all that
|
10
|
+
include the substring 'my-product' or 'their-product'
|
11
|
+
|
12
|
+
brigit grab ~/gitosis-admin my-product their-product
|
13
|
+
|
14
|
+
The same, but clone all repositories:
|
15
|
+
|
16
|
+
brigit grab ~/gitosis-admin
|
data/help/hop.rdoc
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Change submodule references in repositories.
|
2
|
+
|
3
|
+
== Syntax
|
4
|
+
|
5
|
+
brigit hop SUBMODULE_URL [OPTIONS] [REPO_PATHS, ...]
|
6
|
+
|
7
|
+
== Notes
|
8
|
+
|
9
|
+
* For safety reasons:
|
10
|
+
* It WILL NOT change a submodule that has uncommitted changes; the
|
11
|
+
submodule must be pristine. You need to handle these submodules manually.
|
12
|
+
* It does not currently commit the updated submodule reference in the parent
|
13
|
+
repository; the list of modified repos are output after the command
|
14
|
+
is executed; you still need to commit and push manually.
|
15
|
+
* It will do a fresh pull from the submodule's origin before checking out the
|
16
|
+
reference you select with the -r/--ref option (default: 'master')
|
17
|
+
|
18
|
+
== Examples
|
19
|
+
|
20
|
+
Update all submodules pointing to remote origin 'git@example.com:mine' in
|
21
|
+
repositories under PWD (or just PWD, if it's a repo itself) to a whatever
|
22
|
+
the current commit is on the 'master' branch.
|
23
|
+
|
24
|
+
git hop git@example.com:mine
|
25
|
+
|
26
|
+
Do the same, but only in the foo/bar repository
|
27
|
+
|
28
|
+
git hop git@example.com:mine foo/bar
|
29
|
+
|
30
|
+
The same, but this time set the submodule commit to the 'alternate' branch
|
31
|
+
|
32
|
+
git hop git@example.com:mine -r alternate foo/bar
|
33
|
+
|
34
|
+
And this time, commit SHA 25b306c73
|
35
|
+
|
36
|
+
git hop git@example.com:mine -r 25b306c73 foo/bar
|
data/help/map.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Graphs of submodules in this repository
|
2
|
+
|
3
|
+
== Syntax
|
4
|
+
|
5
|
+
brigit map [OPTIONS]
|
6
|
+
|
7
|
+
== Notes
|
8
|
+
|
9
|
+
You must be in the Git repository when this command is executed.
|
10
|
+
|
11
|
+
== Examples
|
12
|
+
|
13
|
+
Output DOT-format output for current repository structure:
|
14
|
+
|
15
|
+
brigit map
|
16
|
+
|
17
|
+
Display graph of current repository structure:
|
18
|
+
|
19
|
+
brigit map -o
|
data/help/update.rdoc
ADDED
data/lib/brigit/cli.rb
CHANGED
@@ -5,55 +5,24 @@ module Brigit
|
|
5
5
|
class CLI
|
6
6
|
|
7
7
|
def parse(*args)
|
8
|
-
|
9
|
-
|
10
|
-
yield command.new(self.class.options, *args)
|
8
|
+
if (command = Command[args.shift])
|
9
|
+
command.new(*args)
|
11
10
|
else
|
12
|
-
abort "No command given.\n#{
|
11
|
+
abort "No command given.\n\n#{self.class.usage}"
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
|
-
def self.usage
|
17
|
-
parser.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
#######
|
21
|
-
private
|
22
|
-
#######
|
23
14
|
|
24
|
-
def self.
|
25
|
-
|
15
|
+
def self.banner
|
16
|
+
%{Brigit (v#{Version::STRING}) Submodule utilities for Git}
|
26
17
|
end
|
27
|
-
|
28
|
-
def self.parser
|
29
|
-
|
30
|
-
command_list = Command.list.map { |command| " * #{command.name}: #{command.help}" }.join("\n")
|
31
|
-
|
32
|
-
options.inventory = {}
|
33
|
-
|
34
|
-
@parser ||= OptionParser.new do |opts|
|
35
|
-
|
36
|
-
opts.banner = %("Brigit," Submodule utilities for Git\nUSAGE: brigit COMMAND [OPTIONS])
|
37
|
-
|
38
|
-
opts.separator "COMMANDS:\n#{command_list}\n"
|
39
18
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
opts.on('-o', '--open', "Open with Preview.app (`map' only, requires OSX & `dot' in PATH)") do
|
49
|
-
options.open = true
|
50
|
-
end
|
51
|
-
|
52
|
-
opts.on_tail('-h', '--help', 'Show this message') do
|
53
|
-
abort opts.to_s
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
19
|
+
def self.usage
|
20
|
+
lines = [
|
21
|
+
banner,
|
22
|
+
%{COMMANDS: (`COMMAND --help' for documentation)},
|
23
|
+
*Command.list.map { |cmd| " #{cmd.name}" }.sort
|
24
|
+
]
|
25
|
+
lines.join "\n"
|
57
26
|
end
|
58
27
|
|
59
28
|
end
|
@@ -1,29 +1,65 @@
|
|
1
1
|
require 'brigit/listable'
|
2
2
|
require 'brigit/fallible'
|
3
|
+
require 'brigit/pretending'
|
4
|
+
|
3
5
|
|
4
6
|
module Brigit
|
5
7
|
|
6
8
|
class Command
|
7
9
|
include Listable
|
8
10
|
include Fallible
|
11
|
+
include Pretending
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
def self.help
|
14
|
+
@help ||= begin
|
15
|
+
help_file = File.dirname(__FILE__) << "/../../../help/#{name}.rdoc"
|
16
|
+
if File.file?(help_file)
|
17
|
+
File.read(help_file)
|
18
|
+
else
|
19
|
+
"Sorry, there is no documentation for this command."
|
20
|
+
end
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
|
-
attr_reader :
|
15
|
-
def initialize(
|
16
|
-
@options = options
|
24
|
+
attr_reader :args
|
25
|
+
def initialize(*args)
|
17
26
|
@args = args
|
18
27
|
end
|
19
28
|
|
20
|
-
def
|
21
|
-
|
29
|
+
def run
|
30
|
+
yield parser if block_given?
|
31
|
+
parser.parse!(args)
|
22
32
|
end
|
23
33
|
|
24
34
|
#######
|
25
35
|
private
|
26
36
|
#######
|
37
|
+
|
38
|
+
def say(message)
|
39
|
+
message = pretending? ? "{PRETENDING} #{message}" : message
|
40
|
+
$stderr.puts message
|
41
|
+
end
|
42
|
+
|
43
|
+
def sh(command)
|
44
|
+
if pretending?
|
45
|
+
say command
|
46
|
+
else
|
47
|
+
system command
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_repo!
|
52
|
+
raise ArgumentError, "Must be in Git repository" unless repo?
|
53
|
+
end
|
54
|
+
|
55
|
+
def parser
|
56
|
+
@parser ||= OptionParser.new do |opts|
|
57
|
+
opts.banner = CLI.banner + "\n---\n= Help on the `#{self.class.name}' command\n\n" + self.class.help + "\n\n== Options\n"
|
58
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
59
|
+
abort opts.to_s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
27
63
|
|
28
64
|
def repo?
|
29
65
|
File.directory?(File.join(Dir.pwd, '.git'))
|
@@ -5,20 +5,16 @@ module Brigit
|
|
5
5
|
|
6
6
|
class GrabCommand < Command
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def execute!
|
11
|
-
validate!
|
8
|
+
def run
|
9
|
+
super { |parser| add_pretend_to parser }
|
12
10
|
matching_repositories.each do |name, location|
|
13
11
|
if File.exists?(name)
|
14
|
-
|
12
|
+
say "#{name}: Already exists, skipping..."
|
15
13
|
else
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
updater.execute!
|
21
|
-
end
|
14
|
+
say "#{name}: Cloning from #{location} ..."
|
15
|
+
sh "git clone '#{location}' '#{name}'"
|
16
|
+
say "#{name}: Updating submodules ..."
|
17
|
+
update name
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
@@ -27,22 +23,26 @@ module Brigit
|
|
27
23
|
private
|
28
24
|
#######
|
29
25
|
|
30
|
-
def
|
31
|
-
|
26
|
+
def update(name)
|
27
|
+
if pretending?
|
28
|
+
say "(Would update submodules for `#{name}')"
|
29
|
+
else
|
30
|
+
if File.directory?(name)
|
31
|
+
Dir.chdir name do
|
32
|
+
UpdateCommand.new.run
|
33
|
+
end
|
34
|
+
else
|
35
|
+
say "ERROR: Directory #{name} was not created; skipping..."
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
33
|
-
|
34
|
-
def
|
35
|
-
|
36
|
-
list = Inventory.listing { |name| "--#{name}" }
|
37
|
-
fail "Can't find list of repositories; need to set #{list}"
|
38
|
-
end
|
39
|
+
|
40
|
+
def inventory
|
41
|
+
@inventory ||= GitosisInventory.new(args.shift)
|
39
42
|
end
|
40
43
|
|
41
44
|
def all_repositories
|
42
|
-
|
43
|
-
source = klass.new(path)
|
44
|
-
all.merge(source.repositories)
|
45
|
-
end
|
45
|
+
inventory.repositories
|
46
46
|
end
|
47
47
|
|
48
48
|
def matching_repositories
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'brigit/commands/command'
|
2
|
+
|
3
|
+
module Brigit
|
4
|
+
|
5
|
+
class HopCommand < Command
|
6
|
+
|
7
|
+
def run
|
8
|
+
ref = default_ref
|
9
|
+
super do |parser|
|
10
|
+
parser.on('-r TREE-ISH', '--ref', "(default: `#{ref}')") do |treeish|
|
11
|
+
ref = treeish
|
12
|
+
end
|
13
|
+
add_pretend_to parser
|
14
|
+
end
|
15
|
+
check_url!
|
16
|
+
changed = []
|
17
|
+
errors = []
|
18
|
+
submodules.each do |path, parent|
|
19
|
+
Dir.chdir path do
|
20
|
+
say "cd #{path}"
|
21
|
+
if clean?
|
22
|
+
sh 'git pull origin master'
|
23
|
+
sh "git checkout '#{ref}'"
|
24
|
+
changed << parent
|
25
|
+
else
|
26
|
+
say "Working directory isn't clean, skipping"
|
27
|
+
errors << path
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
if changed.any?
|
32
|
+
say "---\nPlease check and commit the following parent repositories:\n#{format_list changed}"
|
33
|
+
end
|
34
|
+
if errors.any?
|
35
|
+
say "---\nCould not update the following locations:\n#{format_list errors}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#######
|
40
|
+
private
|
41
|
+
#######
|
42
|
+
|
43
|
+
def format_list(list)
|
44
|
+
list.map { |item| " #{item}" }.join("\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
def clean?
|
48
|
+
`git status` =~ /working directory clean/
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid?(path)
|
52
|
+
return false unless Brigit.submodule?(path)
|
53
|
+
config_file = File.join(path, '.git/config')
|
54
|
+
url = config_parser.parse(File.readlines(config_file))['remote "origin"']['url'] rescue nil
|
55
|
+
return false unless url
|
56
|
+
normalize(submodule_url) == normalize(url)
|
57
|
+
end
|
58
|
+
|
59
|
+
def config_parser
|
60
|
+
@config_parser ||= ConfigParser.new
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_url!
|
64
|
+
fail "Submodule URL required" unless submodule_url
|
65
|
+
end
|
66
|
+
|
67
|
+
def normalize(url)
|
68
|
+
url =~ /\.git$/ ? url : "#{url}.git"
|
69
|
+
end
|
70
|
+
|
71
|
+
def submodule_url
|
72
|
+
@submodule_url ||= args.shift
|
73
|
+
end
|
74
|
+
|
75
|
+
def submodules
|
76
|
+
@submodules ||= begin
|
77
|
+
list = []
|
78
|
+
Brigit.at_repos(true) do |path|
|
79
|
+
list << [path, Brigit.parent_of(path)] if valid?(path)
|
80
|
+
end
|
81
|
+
list
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def default_ref
|
86
|
+
'master'
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|