brigit 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +6 -1
- data/brigit.gemspec +4 -4
- data/lib/brigit/commands/grab_command.rb +64 -0
- data/lib/brigit/fallible.rb +11 -0
- data/lib/brigit/inventories/gitosis_inventory.rb +65 -0
- data/lib/brigit/inventories/inventory.rb +21 -0
- data/lib/brigit/listable.rb +37 -0
- data/lib/brigit/version.rb +1 -1
- metadata +12 -2
data/Manifest
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
bin/brigit
|
2
2
|
lib/brigit/cli.rb
|
3
3
|
lib/brigit/commands/command.rb
|
4
|
+
lib/brigit/commands/grab_command.rb
|
4
5
|
lib/brigit/commands/map_command.rb
|
5
6
|
lib/brigit/commands/update_command.rb
|
6
7
|
lib/brigit/config_parser.rb
|
8
|
+
lib/brigit/fallible.rb
|
9
|
+
lib/brigit/inventories/gitosis_inventory.rb
|
10
|
+
lib/brigit/inventories/inventory.rb
|
11
|
+
lib/brigit/listable.rb
|
7
12
|
lib/brigit/version.rb
|
8
13
|
lib/brigit.rb
|
9
14
|
lib/ext/option_parser.rb
|
15
|
+
Manifest
|
10
16
|
Rakefile
|
11
17
|
README.rdoc
|
12
18
|
test/config_parser_test.rb
|
13
19
|
test/fixtures/example.conf
|
14
20
|
test/test_helper.rb
|
15
|
-
Manifest
|
data/brigit.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Brigit-0.8.
|
2
|
+
# Gem::Specification for Brigit-0.8.2
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{brigit}
|
7
|
-
s.version = "0.8.
|
7
|
+
s.version = "0.8.2"
|
8
8
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
10
|
s.authors = ["FiveRuns Development Team"]
|
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = %q{Git utilities}
|
14
14
|
s.email = %q{dev@fiveruns.com}
|
15
15
|
s.executables = ["brigit"]
|
16
|
-
s.extra_rdoc_files = ["bin/brigit", "lib/brigit/cli.rb", "lib/brigit/commands/command.rb", "lib/brigit/commands/map_command.rb", "lib/brigit/commands/update_command.rb", "lib/brigit/config_parser.rb", "lib/brigit/version.rb", "lib/brigit.rb", "lib/ext/option_parser.rb", "README.rdoc"]
|
17
|
-
s.files = ["bin/brigit", "lib/brigit/cli.rb", "lib/brigit/commands/command.rb", "lib/brigit/commands/map_command.rb", "lib/brigit/commands/update_command.rb", "lib/brigit/config_parser.rb", "lib/brigit/version.rb", "lib/brigit.rb", "lib/ext/option_parser.rb", "Rakefile", "README.rdoc", "test/config_parser_test.rb", "test/fixtures/example.conf", "test/test_helper.rb", "
|
16
|
+
s.extra_rdoc_files = ["bin/brigit", "lib/brigit/cli.rb", "lib/brigit/commands/command.rb", "lib/brigit/commands/grab_command.rb", "lib/brigit/commands/map_command.rb", "lib/brigit/commands/update_command.rb", "lib/brigit/config_parser.rb", "lib/brigit/fallible.rb", "lib/brigit/inventories/gitosis_inventory.rb", "lib/brigit/inventories/inventory.rb", "lib/brigit/listable.rb", "lib/brigit/version.rb", "lib/brigit.rb", "lib/ext/option_parser.rb", "README.rdoc"]
|
17
|
+
s.files = ["bin/brigit", "lib/brigit/cli.rb", "lib/brigit/commands/command.rb", "lib/brigit/commands/grab_command.rb", "lib/brigit/commands/map_command.rb", "lib/brigit/commands/update_command.rb", "lib/brigit/config_parser.rb", "lib/brigit/fallible.rb", "lib/brigit/inventories/gitosis_inventory.rb", "lib/brigit/inventories/inventory.rb", "lib/brigit/listable.rb", "lib/brigit/version.rb", "lib/brigit.rb", "lib/ext/option_parser.rb", "Manifest", "Rakefile", "README.rdoc", "test/config_parser_test.rb", "test/fixtures/example.conf", "test/test_helper.rb", "brigit.gemspec"]
|
18
18
|
s.has_rdoc = true
|
19
19
|
s.homepage = %q{http://github.com/fiveruns/brigit}
|
20
20
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Brigit", "--main", "README.rdoc"]
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'brigit/commands/command'
|
2
|
+
require 'brigit/commands/update_command'
|
3
|
+
|
4
|
+
module Brigit
|
5
|
+
|
6
|
+
class GrabCommand < Command
|
7
|
+
|
8
|
+
self.help = "Grab repos matching optional pattern from a gitosis-admin config"
|
9
|
+
|
10
|
+
def execute!
|
11
|
+
validate!
|
12
|
+
matching_repositories.each do |name, location|
|
13
|
+
if File.exists?(name)
|
14
|
+
STDERR.puts "#{name}: Already exists, skipping..."
|
15
|
+
else
|
16
|
+
STDERR.puts "#{name}: Cloning from #{location} ..."
|
17
|
+
system "git clone '#{location}' '#{name}'"
|
18
|
+
STDERR.puts "#{name}: Updating submodules ..."
|
19
|
+
Dir.chdir name do
|
20
|
+
updater.execute!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#######
|
27
|
+
private
|
28
|
+
#######
|
29
|
+
|
30
|
+
def updater
|
31
|
+
@updater ||= UpdateCommand.new(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate!
|
35
|
+
if options.inventory.empty?
|
36
|
+
list = Inventory.listing { |name| "--#{name}" }
|
37
|
+
fail "Can't find list of repositories; need to set #{list}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def all_repositories
|
42
|
+
options.inventory.inject({}) do |all, (klass, path)|
|
43
|
+
source = klass.new(path)
|
44
|
+
all.merge(source.repositories)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def matching_repositories
|
49
|
+
if args.empty?
|
50
|
+
all_repositories
|
51
|
+
else
|
52
|
+
matching = all_repositories.select do |name, location|
|
53
|
+
args.any? { |arg| name.include?(arg) }
|
54
|
+
end
|
55
|
+
Hash[*matching.flatten]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'brigit/inventories/inventory'
|
2
|
+
require 'brigit/config_parser'
|
3
|
+
|
4
|
+
module Brigit
|
5
|
+
|
6
|
+
class GitosisInventory < Inventory
|
7
|
+
|
8
|
+
def repositories
|
9
|
+
@repositories ||= begin
|
10
|
+
validate_path!
|
11
|
+
sections.values.inject({}) do |all, section|
|
12
|
+
%w(writable readonly).each do |field|
|
13
|
+
tokenize(section[field]).each do |name|
|
14
|
+
all[name] = repo_path(name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
all
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
#######
|
23
|
+
private
|
24
|
+
#######
|
25
|
+
|
26
|
+
def tokenize(text)
|
27
|
+
return [] unless text
|
28
|
+
text.scan(/(\S+)/).flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
def validate_path!
|
32
|
+
fail "No such file: #{gitosis_conf}" unless File.file?(gitosis_conf)
|
33
|
+
fail "gitosis-admin is not a Git repository" unless File.file?(git_config)
|
34
|
+
end
|
35
|
+
|
36
|
+
def gitosis_conf
|
37
|
+
File.join(path, "gitosis.conf")
|
38
|
+
end
|
39
|
+
|
40
|
+
def git_config
|
41
|
+
File.join(path, '.git/config')
|
42
|
+
end
|
43
|
+
|
44
|
+
def base
|
45
|
+
@base ||= begin
|
46
|
+
config = parser.parse(File.readlines(git_config))
|
47
|
+
config[%|remote "origin"|]['url'].sub(/:.*?$/, '')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def repo_path(component)
|
52
|
+
[base, component].join(':')
|
53
|
+
end
|
54
|
+
|
55
|
+
def sections
|
56
|
+
@sections ||= parser.parse(File.readlines(gitosis_conf))
|
57
|
+
end
|
58
|
+
|
59
|
+
def parser
|
60
|
+
@parser ||= ConfigParser.new
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'brigit/listable'
|
2
|
+
require 'brigit/fallible'
|
3
|
+
|
4
|
+
module Brigit
|
5
|
+
|
6
|
+
class Inventory
|
7
|
+
include Listable
|
8
|
+
include Fallible
|
9
|
+
|
10
|
+
attr_reader :path
|
11
|
+
def initialize(path)
|
12
|
+
@path = path
|
13
|
+
end
|
14
|
+
|
15
|
+
def repositories
|
16
|
+
raise NotImplementedError, 'Abstract'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Brigit
|
2
|
+
|
3
|
+
module Listable
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def [](name)
|
12
|
+
list.detect { |klass| klass.name == name }
|
13
|
+
end
|
14
|
+
|
15
|
+
def inherited(klass)
|
16
|
+
list << klass
|
17
|
+
end
|
18
|
+
|
19
|
+
def list
|
20
|
+
@list ||= []
|
21
|
+
end
|
22
|
+
|
23
|
+
def listing
|
24
|
+
list.map do |l|
|
25
|
+
block_given? ? yield(l.name) : l.name
|
26
|
+
end.join(', ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def name
|
30
|
+
to_s.sub(/^.+::(.+?)[A-Z][a-z]+$/, '\1').downcase
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/brigit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brigit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FiveRuns Development Team
|
@@ -23,9 +23,14 @@ extra_rdoc_files:
|
|
23
23
|
- bin/brigit
|
24
24
|
- lib/brigit/cli.rb
|
25
25
|
- lib/brigit/commands/command.rb
|
26
|
+
- lib/brigit/commands/grab_command.rb
|
26
27
|
- lib/brigit/commands/map_command.rb
|
27
28
|
- lib/brigit/commands/update_command.rb
|
28
29
|
- lib/brigit/config_parser.rb
|
30
|
+
- lib/brigit/fallible.rb
|
31
|
+
- lib/brigit/inventories/gitosis_inventory.rb
|
32
|
+
- lib/brigit/inventories/inventory.rb
|
33
|
+
- lib/brigit/listable.rb
|
29
34
|
- lib/brigit/version.rb
|
30
35
|
- lib/brigit.rb
|
31
36
|
- lib/ext/option_parser.rb
|
@@ -34,18 +39,23 @@ files:
|
|
34
39
|
- bin/brigit
|
35
40
|
- lib/brigit/cli.rb
|
36
41
|
- lib/brigit/commands/command.rb
|
42
|
+
- lib/brigit/commands/grab_command.rb
|
37
43
|
- lib/brigit/commands/map_command.rb
|
38
44
|
- lib/brigit/commands/update_command.rb
|
39
45
|
- lib/brigit/config_parser.rb
|
46
|
+
- lib/brigit/fallible.rb
|
47
|
+
- lib/brigit/inventories/gitosis_inventory.rb
|
48
|
+
- lib/brigit/inventories/inventory.rb
|
49
|
+
- lib/brigit/listable.rb
|
40
50
|
- lib/brigit/version.rb
|
41
51
|
- lib/brigit.rb
|
42
52
|
- lib/ext/option_parser.rb
|
53
|
+
- Manifest
|
43
54
|
- Rakefile
|
44
55
|
- README.rdoc
|
45
56
|
- test/config_parser_test.rb
|
46
57
|
- test/fixtures/example.conf
|
47
58
|
- test/test_helper.rb
|
48
|
-
- Manifest
|
49
59
|
- brigit.gemspec
|
50
60
|
has_rdoc: true
|
51
61
|
homepage: http://github.com/fiveruns/brigit
|