git-multirepo 1.0.0.beta21 → 1.0.0.beta24
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 +4 -4
- data/.gitignore +38 -38
- data/.rspec +2 -2
- data/Gemfile +4 -4
- data/Gemfile.lock +37 -37
- data/LICENSE +22 -22
- data/README.md +141 -139
- data/Rakefile +2 -2
- data/bin/multi +10 -10
- data/docs/git-multirepo-cheatsheet.docx +0 -0
- data/git-multirepo.gemspec +29 -29
- data/lib/commands.rb +11 -11
- data/lib/git-multirepo.rb +2 -2
- data/lib/info.rb +4 -4
- data/lib/multirepo/commands/add-command.rb +51 -51
- data/lib/multirepo/commands/branch-command.rb +52 -52
- data/lib/multirepo/commands/checkout-command.rb +119 -119
- data/lib/multirepo/commands/clone-command.rb +69 -69
- data/lib/multirepo/commands/command.rb +58 -50
- data/lib/multirepo/commands/fetch-command.rb +23 -23
- data/lib/multirepo/commands/init-command.rb +51 -51
- data/lib/multirepo/commands/install-command.rb +87 -87
- data/lib/multirepo/commands/open-command.rb +25 -25
- data/lib/multirepo/commands/remove-command.rb +48 -48
- data/lib/multirepo/commands/uninit-command.rb +20 -20
- data/lib/multirepo/commands/update-command.rb +47 -47
- data/lib/multirepo/config.rb +15 -12
- data/lib/multirepo/files/config-entry.rb +34 -34
- data/lib/multirepo/files/config-file.rb +37 -37
- data/lib/multirepo/files/lock-entry.rb +25 -25
- data/lib/multirepo/files/lock-file.rb +39 -39
- data/lib/multirepo/git/branch.rb +27 -27
- data/lib/multirepo/git/change.rb +10 -10
- data/lib/multirepo/git/git.rb +42 -38
- data/lib/multirepo/git/remote.rb +15 -15
- data/lib/multirepo/git/repo.rb +66 -66
- data/lib/multirepo/hooks/post-merge-hook.rb +19 -19
- data/lib/multirepo/hooks/pre-commit-hook.rb +25 -25
- data/lib/multirepo/hooks/prepare-commit-msg-hook.rb +27 -27
- data/lib/multirepo/multirepo-exception.rb +5 -5
- data/lib/multirepo/utility/console.rb +51 -51
- data/lib/multirepo/utility/runner.rb +32 -32
- data/lib/multirepo/utility/utils.rb +51 -51
- data/resources/post-merge +5 -5
- data/resources/pre-commit +5 -5
- data/resources/prepare-commit-msg +5 -5
- data/spec/integration/init_spec.rb +22 -22
- data/spec/spec_helper.rb +89 -89
- metadata +4 -3
@@ -1,20 +1,20 @@
|
|
1
|
-
require "multirepo/files/lock-file"
|
2
|
-
require "multirepo/utility/console"
|
3
|
-
|
4
|
-
module MultiRepo
|
5
|
-
class PostMergeHook
|
6
|
-
def self.run
|
7
|
-
Config.instance.running_git_hook = true
|
8
|
-
|
9
|
-
Console.log_step("
|
10
|
-
|
11
|
-
LockFile.update
|
12
|
-
Console.log_info("
|
13
|
-
|
14
|
-
LockFile.commit("Automatic post-merge multirepo lock file update")
|
15
|
-
Console.log_info("
|
16
|
-
|
17
|
-
exit 0 # Success!
|
18
|
-
end
|
19
|
-
end
|
1
|
+
require "multirepo/files/lock-file"
|
2
|
+
require "multirepo/utility/console"
|
3
|
+
|
4
|
+
module MultiRepo
|
5
|
+
class PostMergeHook
|
6
|
+
def self.run
|
7
|
+
Config.instance.running_git_hook = true
|
8
|
+
|
9
|
+
Console.log_step("Performing post-merge operations...")
|
10
|
+
|
11
|
+
LockFile.update
|
12
|
+
Console.log_info("Updated the lock file with current HEAD revisions for all dependencies")
|
13
|
+
|
14
|
+
LockFile.commit("Automatic post-merge multirepo lock file update")
|
15
|
+
Console.log_info("Committed the updated lock file")
|
16
|
+
|
17
|
+
exit 0 # Success!
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require "multirepo/files/config-file"
|
2
|
-
require "multirepo/files/lock-file"
|
3
|
-
require "multirepo/utility/utils"
|
4
|
-
require "multirepo/utility/console"
|
5
|
-
|
6
|
-
module MultiRepo
|
7
|
-
class PreCommitHook
|
8
|
-
def self.run
|
9
|
-
Config.instance.running_git_hook = true
|
10
|
-
|
11
|
-
Console.log_step("
|
12
|
-
|
13
|
-
dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
|
14
|
-
|
15
|
-
if !dependencies_clean
|
16
|
-
Console.log_error("
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
|
20
|
-
LockFile.update
|
21
|
-
Console.log_info("
|
22
|
-
|
23
|
-
exit 0 # Success!
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require "multirepo/files/config-file"
|
2
|
+
require "multirepo/files/lock-file"
|
3
|
+
require "multirepo/utility/utils"
|
4
|
+
require "multirepo/utility/console"
|
5
|
+
|
6
|
+
module MultiRepo
|
7
|
+
class PreCommitHook
|
8
|
+
def self.run
|
9
|
+
Config.instance.running_git_hook = true
|
10
|
+
|
11
|
+
Console.log_step("Performing pre-commit operations...")
|
12
|
+
|
13
|
+
dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
|
14
|
+
|
15
|
+
if !dependencies_clean
|
16
|
+
Console.log_error("You must commit changes to your dependencies before you can commit this repo")
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
LockFile.update
|
21
|
+
Console.log_info("Updated and staged lock file with current HEAD revisions for all dependencies")
|
22
|
+
|
23
|
+
exit 0 # Success!
|
24
|
+
end
|
25
|
+
end
|
26
26
|
end
|
@@ -1,28 +1,28 @@
|
|
1
|
-
require "multirepo/files/config-file"
|
2
|
-
require "multirepo/files/lock-file"
|
3
|
-
require "multirepo/utility/utils"
|
4
|
-
require "multirepo/utility/console"
|
5
|
-
|
6
|
-
module MultiRepo
|
7
|
-
class PrepareCommitMsgHook
|
8
|
-
def self.run(argv)
|
9
|
-
Config.instance.running_git_hook = true
|
10
|
-
|
11
|
-
pre_merge if argv[1] == "merge"
|
12
|
-
|
13
|
-
exit 0 # Success!
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.pre_merge
|
17
|
-
Console.log_step("
|
18
|
-
ensure_dependencies_clean
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.ensure_dependencies_clean
|
22
|
-
unless Utils.ensure_dependencies_clean(ConfigFile.load)
|
23
|
-
Console.log_error("
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
require "multirepo/files/config-file"
|
2
|
+
require "multirepo/files/lock-file"
|
3
|
+
require "multirepo/utility/utils"
|
4
|
+
require "multirepo/utility/console"
|
5
|
+
|
6
|
+
module MultiRepo
|
7
|
+
class PrepareCommitMsgHook
|
8
|
+
def self.run(argv)
|
9
|
+
Config.instance.running_git_hook = true
|
10
|
+
|
11
|
+
pre_merge if argv[1] == "merge"
|
12
|
+
|
13
|
+
exit 0 # Success!
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.pre_merge
|
17
|
+
Console.log_step("Performing pre-merge operations...")
|
18
|
+
ensure_dependencies_clean
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ensure_dependencies_clean
|
22
|
+
unless Utils.ensure_dependencies_clean(ConfigFile.load)
|
23
|
+
Console.log_error("You must commit changes to your dependencies before you can commit this repo")
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
28
|
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
|
-
|
7
|
-
puts $stdout.isatty ? message.bold.green : message
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.log_substep(message)
|
11
|
-
|
12
|
-
puts $stdout.isatty ? message.blue : message
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.log_info(message)
|
16
|
-
|
17
|
-
puts $stdout.isatty ? message.white : message
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.log_warning(message)
|
21
|
-
|
22
|
-
puts $stdout.isatty ? message.yellow : message
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.log_error(message)
|
26
|
-
|
27
|
-
puts $stdout.isatty ? message.red : message
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.ask_yes_no(message)
|
31
|
-
answered = false
|
32
|
-
while !answered
|
33
|
-
|
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.
|
49
|
-
print $stdout.isatty ? "> ".white : ""
|
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,33 +1,33 @@
|
|
1
|
-
require "open3"
|
2
|
-
require "multirepo/utility/console"
|
3
|
-
|
4
|
-
module MultiRepo
|
5
|
-
class Runner
|
6
|
-
class Verbosity
|
7
|
-
NEVER_OUTPUT = 0
|
8
|
-
ALWAYS_OUTPUT = 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
|
-
lines = []
|
18
|
-
Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
|
19
|
-
stdout_and_stderr.each do |line|
|
20
|
-
Console.log_info(line.rstrip) if verbosity == Verbosity::ALWAYS_OUTPUT || Config.instance.verbose
|
21
|
-
lines << line
|
22
|
-
end
|
23
|
-
@last_command_succeeded = thread.value.success?
|
24
|
-
end
|
25
|
-
|
26
|
-
output = lines.join("").rstrip
|
27
|
-
|
28
|
-
Console.log_error(output) if !@last_command_succeeded && verbosity == Verbosity::OUTPUT_ON_ERROR
|
29
|
-
|
30
|
-
return output
|
31
|
-
end
|
32
|
-
end
|
1
|
+
require "open3"
|
2
|
+
require "multirepo/utility/console"
|
3
|
+
|
4
|
+
module MultiRepo
|
5
|
+
class Runner
|
6
|
+
class Verbosity
|
7
|
+
NEVER_OUTPUT = 0
|
8
|
+
ALWAYS_OUTPUT = 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
|
+
lines = []
|
18
|
+
Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
|
19
|
+
stdout_and_stderr.each do |line|
|
20
|
+
Console.log_info(line.rstrip) if verbosity == Verbosity::ALWAYS_OUTPUT || Config.instance.verbose
|
21
|
+
lines << line
|
22
|
+
end
|
23
|
+
@last_command_succeeded = thread.value.success?
|
24
|
+
end
|
25
|
+
|
26
|
+
output = lines.join("").rstrip
|
27
|
+
|
28
|
+
Console.log_error(output) if !@last_command_succeeded && verbosity == Verbosity::OUTPUT_ON_ERROR
|
29
|
+
|
30
|
+
return output
|
31
|
+
end
|
32
|
+
end
|
33
33
|
end
|
@@ -1,52 +1,52 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class Utils
|
5
|
-
def self.path_for_resource(resource_name)
|
6
|
-
gem_path = Gem::Specification.find_by_name("git-multirepo").gem_dir
|
7
|
-
File.join(gem_path, "resources/#{resource_name}")
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.is_multirepo_enabled(path)
|
11
|
-
File.exists?(File.join(path, ".multirepo")) &&
|
12
|
-
File.exists?(File.join(path, ".multirepo.lock"))
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.install_hook(name, path)
|
16
|
-
FileUtils.cp(path_for_resource(name), File.join(path, ".git/hooks"))
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.sibling_repos
|
20
|
-
sibling_directories = Dir['../*/']
|
21
|
-
sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
|
22
|
-
sibling_repos.delete_if{ |r| Pathname.new(r.path).realpath == Pathname.new(".").realpath }
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.ensure_dependencies_clean(config_entries)
|
26
|
-
clean = true
|
27
|
-
config_entries.each do |e|
|
28
|
-
next unless e.repo.exists?
|
29
|
-
dependency_clean = e.repo.is_clean?
|
30
|
-
clean &= dependency_clean
|
31
|
-
Console.log_info("Dependency '#{e.repo.path}' is clean") if dependency_clean
|
32
|
-
Console.log_warning("Dependency '#{e.repo.path}' contains uncommitted changes") unless dependency_clean
|
33
|
-
end
|
34
|
-
return clean
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.ensure_working_copies_clean(repos)
|
38
|
-
clean = true
|
39
|
-
repos.each do |repo|
|
40
|
-
dependency_clean =
|
41
|
-
clean &= dependency_clean
|
42
|
-
Console.log_warning("Repo '#{repo.path}' contains uncommitted changes") unless dependency_clean
|
43
|
-
end
|
44
|
-
return clean
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.convert_to_windows_path(unix_path)
|
48
|
-
components = Pathname.new(unix_path).each_filename.to_a
|
49
|
-
components.join(File::ALT_SEPARATOR)
|
50
|
-
end
|
51
|
-
end
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class Utils
|
5
|
+
def self.path_for_resource(resource_name)
|
6
|
+
gem_path = Gem::Specification.find_by_name("git-multirepo").gem_dir
|
7
|
+
File.join(gem_path, "resources/#{resource_name}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.is_multirepo_enabled(path)
|
11
|
+
File.exists?(File.join(path, ".multirepo")) &&
|
12
|
+
File.exists?(File.join(path, ".multirepo.lock"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.install_hook(name, path)
|
16
|
+
FileUtils.cp(path_for_resource(name), File.join(path, ".git/hooks"))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.sibling_repos
|
20
|
+
sibling_directories = Dir['../*/']
|
21
|
+
sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
|
22
|
+
sibling_repos.delete_if{ |r| Pathname.new(r.path).realpath == Pathname.new(".").realpath }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.ensure_dependencies_clean(config_entries)
|
26
|
+
clean = true
|
27
|
+
config_entries.each do |e|
|
28
|
+
next unless e.repo.exists?
|
29
|
+
dependency_clean = e.repo.is_clean?
|
30
|
+
clean &= dependency_clean
|
31
|
+
Console.log_info("Dependency '#{e.repo.path}' is clean") if dependency_clean
|
32
|
+
Console.log_warning("Dependency '#{e.repo.path}' contains uncommitted changes") unless dependency_clean
|
33
|
+
end
|
34
|
+
return clean
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.ensure_working_copies_clean(repos)
|
38
|
+
clean = true
|
39
|
+
repos.each do |repo|
|
40
|
+
dependency_clean = repo.is_clean?
|
41
|
+
clean &= dependency_clean
|
42
|
+
Console.log_warning("Repo '#{repo.path}' contains uncommitted changes") unless dependency_clean
|
43
|
+
end
|
44
|
+
return clean
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.convert_to_windows_path(unix_path)
|
48
|
+
components = Pathname.new(unix_path).each_filename.to_a
|
49
|
+
components.join(File::ALT_SEPARATOR)
|
50
|
+
end
|
51
|
+
end
|
52
52
|
end
|
data/resources/post-merge
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "git-multirepo"
|
5
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "git-multirepo"
|
5
|
+
|
6
6
|
MultiRepo::PostMergeHook.run
|