git-multirepo 1.0.0.beta39 → 1.0.0.beta40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +2 -2
- data/.gitbugtraq +3 -3
- data/.gitignore +38 -38
- data/.multirepo.meta +2 -2
- data/.rspec +2 -2
- data/Gemfile +4 -4
- data/Gemfile.lock +42 -42
- data/LICENSE +22 -22
- data/README.md +146 -145
- data/Rakefile +2 -2
- data/bin/multi +10 -10
- data/docs/bug-repros/91565510-repro.sh +20 -20
- data/git-multirepo.gemspec +31 -31
- data/lib/commands.rb +15 -14
- data/lib/git-multirepo.rb +2 -2
- data/lib/info.rb +4 -4
- data/lib/multirepo/commands/add-command.rb +53 -53
- data/lib/multirepo/commands/branch-command.rb +82 -82
- data/lib/multirepo/commands/checkout-command.rb +122 -122
- data/lib/multirepo/commands/clean-command.rb +31 -31
- data/lib/multirepo/commands/clone-command.rb +70 -70
- data/lib/multirepo/commands/command.rb +75 -75
- data/lib/multirepo/commands/do-command.rb +76 -0
- data/lib/multirepo/commands/fetch-command.rb +30 -30
- data/lib/multirepo/commands/graph-command.rb +45 -45
- data/lib/multirepo/commands/init-command.rb +119 -119
- data/lib/multirepo/commands/install-command.rb +103 -103
- data/lib/multirepo/commands/merge-command.rb +167 -167
- data/lib/multirepo/commands/open-command.rb +57 -57
- data/lib/multirepo/commands/remove-command.rb +50 -50
- data/lib/multirepo/commands/uninit-command.rb +20 -20
- data/lib/multirepo/commands/update-command.rb +60 -60
- data/lib/multirepo/config.rb +15 -15
- data/lib/multirepo/files/config-entry.rb +38 -38
- data/lib/multirepo/files/config-file.rb +45 -45
- data/lib/multirepo/files/lock-entry.rb +24 -24
- data/lib/multirepo/files/lock-file.rb +38 -38
- data/lib/multirepo/files/meta-file.rb +40 -40
- data/lib/multirepo/files/tracking-file.rb +8 -8
- data/lib/multirepo/files/tracking-files.rb +46 -46
- data/lib/multirepo/git/branch.rb +30 -30
- data/lib/multirepo/git/change.rb +10 -10
- data/lib/multirepo/git/commit.rb +17 -17
- data/lib/multirepo/git/git-runner.rb +46 -46
- data/lib/multirepo/git/remote.rb +16 -16
- data/lib/multirepo/git/repo.rb +77 -77
- data/lib/multirepo/hooks/post-commit-hook.rb +22 -22
- data/lib/multirepo/hooks/pre-commit-hook.rb +31 -31
- data/lib/multirepo/logic/merge-descriptor.rb +12 -12
- data/lib/multirepo/logic/node.rb +44 -44
- data/lib/multirepo/logic/performer.rb +62 -62
- data/lib/multirepo/logic/revision-selector.rb +34 -34
- data/lib/multirepo/multirepo-exception.rb +5 -5
- data/lib/multirepo/utility/console.rb +51 -51
- data/lib/multirepo/utility/runner.rb +34 -34
- data/lib/multirepo/utility/utils.rb +81 -81
- data/resources/.gitconfig +2 -2
- data/resources/post-commit +5 -5
- data/resources/pre-commit +5 -5
- data/spec/integration/init_spec.rb +18 -18
- data/spec/spec_helper.rb +89 -89
- metadata +4 -3
@@ -1,13 +1,13 @@
|
|
1
|
-
module MultiRepo
|
2
|
-
class MergeDescriptor
|
3
|
-
attr_accessor :name
|
4
|
-
attr_accessor :path
|
5
|
-
attr_accessor :revision
|
6
|
-
|
7
|
-
def initialize(name, path, revision)
|
8
|
-
@name = name
|
9
|
-
@path = path
|
10
|
-
@revision = revision
|
11
|
-
end
|
12
|
-
end
|
1
|
+
module MultiRepo
|
2
|
+
class MergeDescriptor
|
3
|
+
attr_accessor :name
|
4
|
+
attr_accessor :path
|
5
|
+
attr_accessor :revision
|
6
|
+
|
7
|
+
def initialize(name, path, revision)
|
8
|
+
@name = name
|
9
|
+
@path = path
|
10
|
+
@revision = revision
|
11
|
+
end
|
12
|
+
end
|
13
13
|
end
|
data/lib/multirepo/logic/node.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
require "multirepo/files/config-file"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class Node
|
5
|
-
attr_accessor :path
|
6
|
-
attr_accessor :depth
|
7
|
-
|
8
|
-
def initialize(path, depth = 0)
|
9
|
-
@path = path
|
10
|
-
@depth = depth
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
Pathname.new(File.expand_path(@path)).basename.to_s
|
15
|
-
end
|
16
|
-
|
17
|
-
def children
|
18
|
-
return [] unless Utils.is_multirepo_enabled(@path)
|
19
|
-
config_entries = ConfigFile.new(@path).load_entries
|
20
|
-
return config_entries.map { |e| Node.new(e.path, @depth + 1) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def ordered_descendants_including_self
|
24
|
-
return ordered_descendants.push(self)
|
25
|
-
end
|
26
|
-
|
27
|
-
def ordered_descendants
|
28
|
-
descendants = find_descendants_recursive(self)
|
29
|
-
|
30
|
-
unique_paths = descendants.map{ |d| d.path }.uniq
|
31
|
-
unique_nodes = unique_paths.collect do |path|
|
32
|
-
nodes_for_path = descendants.select { |d| d.path == path }
|
33
|
-
next nodes_for_path.sort{ |n| n.depth }.first
|
34
|
-
end
|
35
|
-
|
36
|
-
return unique_nodes.sort_by{ |d| d.depth }.reverse
|
37
|
-
end
|
38
|
-
|
39
|
-
def find_descendants_recursive(node)
|
40
|
-
descendants = node.children
|
41
|
-
descendants.each { |d| descendants.push(*find_descendants_recursive(d)) }
|
42
|
-
return descendants
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require "multirepo/files/config-file"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class Node
|
5
|
+
attr_accessor :path
|
6
|
+
attr_accessor :depth
|
7
|
+
|
8
|
+
def initialize(path, depth = 0)
|
9
|
+
@path = path
|
10
|
+
@depth = depth
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
Pathname.new(File.expand_path(@path)).basename.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def children
|
18
|
+
return [] unless Utils.is_multirepo_enabled(@path)
|
19
|
+
config_entries = ConfigFile.new(@path).load_entries
|
20
|
+
return config_entries.map { |e| Node.new(e.path, @depth + 1) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def ordered_descendants_including_self
|
24
|
+
return ordered_descendants.push(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def ordered_descendants
|
28
|
+
descendants = find_descendants_recursive(self)
|
29
|
+
|
30
|
+
unique_paths = descendants.map{ |d| d.path }.uniq
|
31
|
+
unique_nodes = unique_paths.collect do |path|
|
32
|
+
nodes_for_path = descendants.select { |d| d.path == path }
|
33
|
+
next nodes_for_path.sort{ |n| n.depth }.first
|
34
|
+
end
|
35
|
+
|
36
|
+
return unique_nodes.sort_by{ |d| d.depth }.reverse
|
37
|
+
end
|
38
|
+
|
39
|
+
def find_descendants_recursive(node)
|
40
|
+
descendants = node.children
|
41
|
+
descendants.each { |d| descendants.push(*find_descendants_recursive(d)) }
|
42
|
+
return descendants
|
43
|
+
end
|
44
|
+
end
|
45
45
|
end
|
@@ -1,63 +1,63 @@
|
|
1
|
-
require "ostruct"
|
2
|
-
|
3
|
-
require "multirepo/files/config-file"
|
4
|
-
require "multirepo/files/lock-file"
|
5
|
-
|
6
|
-
module MultiRepo
|
7
|
-
class Performer
|
8
|
-
def self.perform_main_repo_checkout(main_repo, ref)
|
9
|
-
# Make sure the main repo is clean before attempting a checkout
|
10
|
-
unless main_repo.clean?
|
11
|
-
raise MultiRepoException, "Can't checkout #{ref} because the main repo contains uncommitted changes"
|
12
|
-
end
|
13
|
-
|
14
|
-
# Checkout the specified ref
|
15
|
-
unless main_repo.checkout(ref)
|
16
|
-
raise MultiRepoException, "Couldn't perform checkout of main repo #{ref}!"
|
17
|
-
end
|
18
|
-
|
19
|
-
Console.log_substep("Checked out main repo #{ref}")
|
20
|
-
|
21
|
-
# After checkout, make sure we're working with a multirepo-enabled ref
|
22
|
-
unless Utils.is_multirepo_tracked(".")
|
23
|
-
raise MultiRepoException, "Revision #{ref} is not tracked by multirepo!"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.perform_on_dependencies(&operation)
|
28
|
-
config_entries = ConfigFile.new(".").load_entries
|
29
|
-
lock_entries = LockFile.new(".").load_entries
|
30
|
-
|
31
|
-
config_lock_pairs = build_config_lock_pairs(config_entries, lock_entries)
|
32
|
-
dependency_ordered_nodes = Node.new(".").ordered_descendants
|
33
|
-
|
34
|
-
ordered_pairs = dependency_ordered_nodes.map do |node|
|
35
|
-
pair = config_lock_pairs.find { |pair| pair.config_entry.path == node.path }
|
36
|
-
end
|
37
|
-
|
38
|
-
ordered_pairs.each { |pair| operation.call(pair.config_entry, pair.lock_entry) }
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.dependencies
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def self.build_config_lock_pairs(config_entries, lock_entries)
|
48
|
-
lock_entries.map do |lock_entry|
|
49
|
-
config_entry = config_entry_for_lock_entry(config_entries, lock_entry)
|
50
|
-
|
51
|
-
pair = OpenStruct.new
|
52
|
-
pair.config_entry = config_entry
|
53
|
-
pair.lock_entry = lock_entry
|
54
|
-
|
55
|
-
next pair
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.config_entry_for_lock_entry(config_entries, lock_entry)
|
60
|
-
config_entries.find { |config_entry| config_entry.id == lock_entry.id }
|
61
|
-
end
|
62
|
-
end
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
require "multirepo/files/config-file"
|
4
|
+
require "multirepo/files/lock-file"
|
5
|
+
|
6
|
+
module MultiRepo
|
7
|
+
class Performer
|
8
|
+
def self.perform_main_repo_checkout(main_repo, ref)
|
9
|
+
# Make sure the main repo is clean before attempting a checkout
|
10
|
+
unless main_repo.clean?
|
11
|
+
raise MultiRepoException, "Can't checkout #{ref} because the main repo contains uncommitted changes"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Checkout the specified ref
|
15
|
+
unless main_repo.checkout(ref)
|
16
|
+
raise MultiRepoException, "Couldn't perform checkout of main repo #{ref}!"
|
17
|
+
end
|
18
|
+
|
19
|
+
Console.log_substep("Checked out main repo #{ref}")
|
20
|
+
|
21
|
+
# After checkout, make sure we're working with a multirepo-enabled ref
|
22
|
+
unless Utils.is_multirepo_tracked(".")
|
23
|
+
raise MultiRepoException, "Revision #{ref} is not tracked by multirepo!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.perform_on_dependencies(&operation)
|
28
|
+
config_entries = ConfigFile.new(".").load_entries
|
29
|
+
lock_entries = LockFile.new(".").load_entries
|
30
|
+
|
31
|
+
config_lock_pairs = build_config_lock_pairs(config_entries, lock_entries)
|
32
|
+
dependency_ordered_nodes = Node.new(".").ordered_descendants
|
33
|
+
|
34
|
+
ordered_pairs = dependency_ordered_nodes.map do |node|
|
35
|
+
pair = config_lock_pairs.find { |pair| pair.config_entry.path == node.path }
|
36
|
+
end
|
37
|
+
|
38
|
+
ordered_pairs.each { |pair| operation.call(pair.config_entry, pair.lock_entry) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.dependencies
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def self.build_config_lock_pairs(config_entries, lock_entries)
|
48
|
+
lock_entries.map do |lock_entry|
|
49
|
+
config_entry = config_entry_for_lock_entry(config_entries, lock_entry)
|
50
|
+
|
51
|
+
pair = OpenStruct.new
|
52
|
+
pair.config_entry = config_entry
|
53
|
+
pair.lock_entry = lock_entry
|
54
|
+
|
55
|
+
next pair
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.config_entry_for_lock_entry(config_entries, lock_entry)
|
60
|
+
config_entries.find { |config_entry| config_entry.id == lock_entry.id }
|
61
|
+
end
|
62
|
+
end
|
63
63
|
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
module MultiRepo
|
2
|
-
class RevisionSelectionMode
|
3
|
-
AS_LOCK = 0
|
4
|
-
LATEST = 1
|
5
|
-
EXACT = 2
|
6
|
-
|
7
|
-
def self.name_for_mode(mode)
|
8
|
-
case mode
|
9
|
-
when AS_LOCK; "as-lock"
|
10
|
-
when LATEST; "latest"
|
11
|
-
when EXACT; "exact"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class RevisionSelector
|
17
|
-
def self.mode_for_args(checkout_latest, checkout_exact)
|
18
|
-
if checkout_latest then
|
19
|
-
RevisionSelectionMode::LATEST
|
20
|
-
elsif checkout_exact then
|
21
|
-
RevisionSelectionMode::EXACT
|
22
|
-
else
|
23
|
-
RevisionSelectionMode::AS_LOCK
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.revision_for_mode(mode, ref, lock_entry)
|
28
|
-
case mode
|
29
|
-
when RevisionSelectionMode::AS_LOCK; lock_entry.head
|
30
|
-
when RevisionSelectionMode::LATEST; lock_entry.branch
|
31
|
-
when RevisionSelectionMode::EXACT; ref
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module MultiRepo
|
2
|
+
class RevisionSelectionMode
|
3
|
+
AS_LOCK = 0
|
4
|
+
LATEST = 1
|
5
|
+
EXACT = 2
|
6
|
+
|
7
|
+
def self.name_for_mode(mode)
|
8
|
+
case mode
|
9
|
+
when AS_LOCK; "as-lock"
|
10
|
+
when LATEST; "latest"
|
11
|
+
when EXACT; "exact"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class RevisionSelector
|
17
|
+
def self.mode_for_args(checkout_latest, checkout_exact)
|
18
|
+
if checkout_latest then
|
19
|
+
RevisionSelectionMode::LATEST
|
20
|
+
elsif checkout_exact then
|
21
|
+
RevisionSelectionMode::EXACT
|
22
|
+
else
|
23
|
+
RevisionSelectionMode::AS_LOCK
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.revision_for_mode(mode, ref, lock_entry)
|
28
|
+
case mode
|
29
|
+
when RevisionSelectionMode::AS_LOCK; lock_entry.head
|
30
|
+
when RevisionSelectionMode::LATEST; lock_entry.branch
|
31
|
+
when RevisionSelectionMode::EXACT; ref
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
35
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require "claide/informative_error"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class MultiRepoException < StandardError
|
5
|
-
end
|
1
|
+
require "claide/informative_error"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class MultiRepoException < StandardError
|
5
|
+
end
|
6
6
|
end
|
@@ -1,52 +1,52 @@
|
|
1
|
-
require "colored"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class Console
|
5
|
-
def self.log_step(message)
|
6
|
-
print_prefix
|
7
|
-
puts $stdout.isatty ? message.bold.green : message
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.log_substep(message)
|
11
|
-
print_prefix
|
12
|
-
puts $stdout.isatty ? message.blue : message
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.log_info(message)
|
16
|
-
print_prefix
|
17
|
-
puts $stdout.isatty ? message.white : message
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.log_warning(message)
|
21
|
-
print_prefix
|
22
|
-
puts $stdout.isatty ? message.yellow : message
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.log_error(message)
|
26
|
-
print_prefix
|
27
|
-
puts $stdout.isatty ? message.red : message
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.ask_yes_no(message)
|
31
|
-
answered = false
|
32
|
-
while !answered
|
33
|
-
print_prefix
|
34
|
-
print message
|
35
|
-
print " (y/n) "
|
36
|
-
|
37
|
-
case $stdin.gets.strip.downcase
|
38
|
-
when "y", "yes"
|
39
|
-
answered = true
|
40
|
-
return true
|
41
|
-
when "n", "no"
|
42
|
-
answered = true
|
43
|
-
return false
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.print_prefix
|
49
|
-
print $stdout.isatty ? "> ".white : "[multirepo] "
|
50
|
-
end
|
51
|
-
end
|
1
|
+
require "colored"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class Console
|
5
|
+
def self.log_step(message)
|
6
|
+
print_prefix
|
7
|
+
puts $stdout.isatty ? message.bold.green : message
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.log_substep(message)
|
11
|
+
print_prefix
|
12
|
+
puts $stdout.isatty ? message.blue : message
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.log_info(message)
|
16
|
+
print_prefix
|
17
|
+
puts $stdout.isatty ? message.white : message
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.log_warning(message)
|
21
|
+
print_prefix
|
22
|
+
puts $stdout.isatty ? message.yellow : message
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.log_error(message)
|
26
|
+
print_prefix
|
27
|
+
puts $stdout.isatty ? message.red : message
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.ask_yes_no(message)
|
31
|
+
answered = false
|
32
|
+
while !answered
|
33
|
+
print_prefix
|
34
|
+
print message
|
35
|
+
print " (y/n) "
|
36
|
+
|
37
|
+
case $stdin.gets.strip.downcase
|
38
|
+
when "y", "yes"
|
39
|
+
answered = true
|
40
|
+
return true
|
41
|
+
when "n", "no"
|
42
|
+
answered = true
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.print_prefix
|
49
|
+
print $stdout.isatty ? "> ".white : "[multirepo] "
|
50
|
+
end
|
51
|
+
end
|
52
52
|
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
require "open3"
|
2
|
-
require "multirepo/utility/console"
|
3
|
-
|
4
|
-
module MultiRepo
|
5
|
-
class Runner
|
6
|
-
class Verbosity
|
7
|
-
OUTPUT_NEVER = 0
|
8
|
-
OUTPUT_ALWAYS = 1
|
9
|
-
OUTPUT_ON_ERROR = 2
|
10
|
-
end
|
11
|
-
|
12
|
-
class << self
|
13
|
-
attr_accessor :last_command_succeeded
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.run(cmd, verbosity)
|
17
|
-
Console.log_info("Command: #{cmd}") if Config.instance.verbose
|
18
|
-
|
19
|
-
lines = []
|
20
|
-
Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
|
21
|
-
stdout_and_stderr.each do |line|
|
22
|
-
Console.log_info("#{line.rstrip}") if verbosity == Verbosity::OUTPUT_ALWAYS || Config.instance.verbose
|
23
|
-
lines << line
|
24
|
-
end
|
25
|
-
@last_command_succeeded = thread.value.success?
|
26
|
-
end
|
27
|
-
|
28
|
-
output = lines.join("").rstrip
|
29
|
-
|
30
|
-
Console.log_error(output) if !@last_command_succeeded && verbosity == Verbosity::OUTPUT_ON_ERROR
|
31
|
-
|
32
|
-
return output
|
33
|
-
end
|
34
|
-
end
|
1
|
+
require "open3"
|
2
|
+
require "multirepo/utility/console"
|
3
|
+
|
4
|
+
module MultiRepo
|
5
|
+
class Runner
|
6
|
+
class Verbosity
|
7
|
+
OUTPUT_NEVER = 0
|
8
|
+
OUTPUT_ALWAYS = 1
|
9
|
+
OUTPUT_ON_ERROR = 2
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_accessor :last_command_succeeded
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.run(cmd, verbosity)
|
17
|
+
Console.log_info("Command: #{cmd}") if Config.instance.verbose
|
18
|
+
|
19
|
+
lines = []
|
20
|
+
Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
|
21
|
+
stdout_and_stderr.each do |line|
|
22
|
+
Console.log_info("#{line.rstrip}") if verbosity == Verbosity::OUTPUT_ALWAYS || Config.instance.verbose
|
23
|
+
lines << line
|
24
|
+
end
|
25
|
+
@last_command_succeeded = thread.value.success?
|
26
|
+
end
|
27
|
+
|
28
|
+
output = lines.join("").rstrip
|
29
|
+
|
30
|
+
Console.log_error(output) if !@last_command_succeeded && verbosity == Verbosity::OUTPUT_ON_ERROR
|
31
|
+
|
32
|
+
return output
|
33
|
+
end
|
34
|
+
end
|
35
35
|
end
|