git-multirepo 1.0.0.beta16 → 1.0.0.beta17
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 +139 -137
- data/Rakefile +2 -2
- data/bin/multi +5 -5
- data/git-multirepo.gemspec +29 -29
- data/lib/commands.rb +12 -12
- data/lib/git-multirepo.rb +2 -1
- data/lib/info.rb +4 -4
- data/lib/multirepo/commands/add-command.rb +51 -44
- data/lib/multirepo/commands/branch-command.rb +52 -52
- data/lib/multirepo/commands/checkout-command.rb +84 -84
- data/lib/multirepo/commands/clone-command.rb +53 -53
- data/lib/multirepo/commands/command.rb +32 -36
- data/lib/multirepo/commands/edit-command.rb +21 -21
- data/lib/multirepo/commands/fetch-command.rb +23 -23
- data/lib/multirepo/commands/init-command.rb +53 -53
- data/lib/multirepo/commands/install-command.rb +68 -68
- 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 +21 -20
- data/lib/multirepo/commands/update-command.rb +50 -50
- data/lib/multirepo/config.rb +12 -12
- data/lib/multirepo/files/config-entry.rb +37 -37
- 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 -38
- data/lib/multirepo/git/branch.rb +27 -27
- data/lib/multirepo/git/change.rb +10 -10
- data/lib/multirepo/git/git.rb +38 -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 +18 -0
- data/lib/multirepo/hooks/pre-commit-hook.rb +23 -23
- 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 +41 -41
- data/resources/post-merge +6 -0
- data/resources/pre-commit +5 -5
- data/spec/integration/init_spec.rb +26 -22
- data/spec/spec_helper.rb +89 -89
- metadata +5 -3
@@ -1,26 +1,26 @@
|
|
1
|
-
require "os"
|
2
|
-
|
3
|
-
require "multirepo/utility/console"
|
4
|
-
require "multirepo/utility/utils"
|
5
|
-
|
6
|
-
module MultiRepo
|
7
|
-
class OpenCommand < Command
|
8
|
-
self.command = "open"
|
9
|
-
self.summary = "Opens all dependencies in the current OS's file explorer."
|
10
|
-
|
11
|
-
def run
|
12
|
-
validate_in_work_tree
|
13
|
-
ensure_multirepo_initialized
|
14
|
-
|
15
|
-
ConfigFile.load.each do |entry|
|
16
|
-
if OS.osx?
|
17
|
-
`open "#{entry.repo.path}"`
|
18
|
-
elsif OS.windows?
|
19
|
-
`explorer "#{Utils.convert_to_windows_path(entry.repo.path)}"`
|
20
|
-
end
|
21
|
-
end
|
22
|
-
rescue MultiRepoException => e
|
23
|
-
Console.log_error(e.message)
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require "os"
|
2
|
+
|
3
|
+
require "multirepo/utility/console"
|
4
|
+
require "multirepo/utility/utils"
|
5
|
+
|
6
|
+
module MultiRepo
|
7
|
+
class OpenCommand < Command
|
8
|
+
self.command = "open"
|
9
|
+
self.summary = "Opens all dependencies in the current OS's file explorer."
|
10
|
+
|
11
|
+
def run
|
12
|
+
validate_in_work_tree
|
13
|
+
ensure_multirepo_initialized
|
14
|
+
|
15
|
+
ConfigFile.load.each do |entry|
|
16
|
+
if OS.osx?
|
17
|
+
`open "#{entry.repo.path}"`
|
18
|
+
elsif OS.windows?
|
19
|
+
`explorer "#{Utils.convert_to_windows_path(entry.repo.path)}"`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
rescue MultiRepoException => e
|
23
|
+
Console.log_error(e.message)
|
24
|
+
end
|
25
|
+
end
|
26
26
|
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
require "multirepo/files/config-file"
|
3
|
-
|
4
|
-
module MultiRepo
|
5
|
-
class RemoveCommand < Command
|
6
|
-
self.command = "remove"
|
7
|
-
self.summary = "Removes the specified dependency from multirepo."
|
8
|
-
|
9
|
-
def self.options
|
10
|
-
[
|
11
|
-
['[path]', 'The relative path to the dependency to remove (e.g. ../MyOldDependency).'],
|
12
|
-
['--delete', 'Delete the dependency on disk in addition to removing it from the multirepo config.']
|
13
|
-
].concat(super)
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(argv)
|
17
|
-
@path = argv.shift_argument
|
18
|
-
@delete = argv.flag?("delete")
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
|
-
def validate!
|
23
|
-
super
|
24
|
-
help! "You must specify a dependency repository to remove" unless @path
|
25
|
-
end
|
26
|
-
|
27
|
-
def run
|
28
|
-
validate_in_work_tree
|
29
|
-
ensure_multirepo_initialized
|
30
|
-
|
31
|
-
repo = Repo.new(@path)
|
32
|
-
entry = ConfigEntry.new(repo)
|
33
|
-
|
34
|
-
if ConfigFile.entry_exists?(entry)
|
35
|
-
ConfigFile.remove_entry(entry)
|
36
|
-
Console.log_step("Removed '#{@path}' from the .multirepo file")
|
37
|
-
|
38
|
-
if @delete
|
39
|
-
FileUtils.rm_rf(@path)
|
40
|
-
Console.log_step("Deleted '#{@path}' from disk")
|
41
|
-
end
|
42
|
-
else
|
43
|
-
raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
|
44
|
-
end
|
45
|
-
rescue MultiRepoException => e
|
46
|
-
Console.log_error(e.message)
|
47
|
-
end
|
48
|
-
end
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
require "multirepo/files/config-file"
|
3
|
+
|
4
|
+
module MultiRepo
|
5
|
+
class RemoveCommand < Command
|
6
|
+
self.command = "remove"
|
7
|
+
self.summary = "Removes the specified dependency from multirepo."
|
8
|
+
|
9
|
+
def self.options
|
10
|
+
[
|
11
|
+
['[path]', 'The relative path to the dependency to remove (e.g. ../MyOldDependency).'],
|
12
|
+
['--delete', 'Delete the dependency on disk in addition to removing it from the multirepo config.']
|
13
|
+
].concat(super)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(argv)
|
17
|
+
@path = argv.shift_argument
|
18
|
+
@delete = argv.flag?("delete")
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate!
|
23
|
+
super
|
24
|
+
help! "You must specify a dependency repository to remove" unless @path
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
validate_in_work_tree
|
29
|
+
ensure_multirepo_initialized
|
30
|
+
|
31
|
+
repo = Repo.new(@path)
|
32
|
+
entry = ConfigEntry.new(repo)
|
33
|
+
|
34
|
+
if ConfigFile.entry_exists?(entry)
|
35
|
+
ConfigFile.remove_entry(entry)
|
36
|
+
Console.log_step("Removed '#{@path}' from the .multirepo file")
|
37
|
+
|
38
|
+
if @delete
|
39
|
+
FileUtils.rm_rf(@path)
|
40
|
+
Console.log_step("Deleted '#{@path}' from disk")
|
41
|
+
end
|
42
|
+
else
|
43
|
+
raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
|
44
|
+
end
|
45
|
+
rescue MultiRepoException => e
|
46
|
+
Console.log_error(e.message)
|
47
|
+
end
|
48
|
+
end
|
49
49
|
end
|
@@ -1,21 +1,22 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class UninitCommand < Command
|
5
|
-
self.command = "uninit"
|
6
|
-
self.summary = "Removes all traces of multirepo in the current multirepo repository."
|
7
|
-
|
8
|
-
def run
|
9
|
-
validate_in_work_tree
|
10
|
-
ensure_multirepo_initialized
|
11
|
-
|
12
|
-
File.delete(".multirepo")
|
13
|
-
File.delete(".multirepo.lock")
|
14
|
-
File.delete(".git/hooks/pre-commit")
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class UninitCommand < Command
|
5
|
+
self.command = "uninit"
|
6
|
+
self.summary = "Removes all traces of multirepo in the current multirepo repository."
|
7
|
+
|
8
|
+
def run
|
9
|
+
validate_in_work_tree
|
10
|
+
ensure_multirepo_initialized
|
11
|
+
|
12
|
+
File.delete(".multirepo")
|
13
|
+
File.delete(".multirepo.lock")
|
14
|
+
File.delete(".git/hooks/pre-commit")
|
15
|
+
File.delete(".git/hooks/post-merge")
|
16
|
+
|
17
|
+
Console.log_step("All traces of multirepo have been removed from this repository")
|
18
|
+
rescue MultiRepoException => e
|
19
|
+
Console.log_error(e.message)
|
20
|
+
end
|
21
|
+
end
|
21
22
|
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class UpdateCommand < Command
|
5
|
-
self.command = "update"
|
6
|
-
self.summary = "Force-updates the multirepo lock file."
|
7
|
-
|
8
|
-
def self.options
|
9
|
-
[
|
10
|
-
['--force', 'Update the lock file even if dependencies contain uncommitted changes.'],
|
11
|
-
['--commit', 'Commit the lock file after updating it.']
|
12
|
-
].concat(super)
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(argv)
|
16
|
-
@commit = argv.flag?("commit")
|
17
|
-
@force = argv.flag?("force")
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def run
|
22
|
-
validate_in_work_tree
|
23
|
-
ensure_multirepo_initialized
|
24
|
-
|
25
|
-
Console.log_step("Updating...")
|
26
|
-
|
27
|
-
dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
|
28
|
-
|
29
|
-
if dependencies_clean
|
30
|
-
LockFile.update
|
31
|
-
Console.log_substep("Updated lock file with latest dependency commits")
|
32
|
-
elsif !dependencies_clean && @force
|
33
|
-
LockFile.update
|
34
|
-
Console.log_warning("Updated lock file with latest dependency commits regardless of uncommitted changes")
|
35
|
-
else
|
36
|
-
raise MultiRepoException, "Can't update because not all dependencies are clean"
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
if @commit
|
42
|
-
Console.log_substep("Committing updated lock file")
|
43
|
-
LockFile.commit
|
44
|
-
end
|
45
|
-
|
46
|
-
Console.log_step("Done!")
|
47
|
-
rescue MultiRepoException => e
|
48
|
-
Console.log_error(e.message)
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class UpdateCommand < Command
|
5
|
+
self.command = "update"
|
6
|
+
self.summary = "Force-updates the multirepo lock file."
|
7
|
+
|
8
|
+
def self.options
|
9
|
+
[
|
10
|
+
['--force', 'Update the lock file even if dependencies contain uncommitted changes.'],
|
11
|
+
['--commit', 'Commit the lock file after updating it.']
|
12
|
+
].concat(super)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(argv)
|
16
|
+
@commit = argv.flag?("commit")
|
17
|
+
@force = argv.flag?("force")
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
validate_in_work_tree
|
23
|
+
ensure_multirepo_initialized
|
24
|
+
|
25
|
+
Console.log_step("Updating...")
|
26
|
+
|
27
|
+
dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
|
28
|
+
|
29
|
+
if dependencies_clean
|
30
|
+
LockFile.update
|
31
|
+
Console.log_substep("Updated lock file with latest dependency commits")
|
32
|
+
elsif !dependencies_clean && @force
|
33
|
+
LockFile.update
|
34
|
+
Console.log_warning("Updated lock file with latest dependency commits regardless of uncommitted changes")
|
35
|
+
else
|
36
|
+
raise MultiRepoException, "Can't update because not all dependencies are clean"
|
37
|
+
end
|
38
|
+
|
39
|
+
install_hooks
|
40
|
+
|
41
|
+
if @commit
|
42
|
+
Console.log_substep("Committing updated lock file")
|
43
|
+
LockFile.commit
|
44
|
+
end
|
45
|
+
|
46
|
+
Console.log_step("Done!")
|
47
|
+
rescue MultiRepoException => e
|
48
|
+
Console.log_error(e.message)
|
49
|
+
end
|
50
|
+
end
|
51
51
|
end
|
data/lib/multirepo/config.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require "singleton"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class Config
|
5
|
-
include Singleton
|
6
|
-
|
7
|
-
attr_accessor :verbose
|
8
|
-
@verbose = false
|
9
|
-
|
10
|
-
attr_accessor :running_git_hook
|
11
|
-
@running_git_hook = false
|
12
|
-
end
|
1
|
+
require "singleton"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class Config
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
attr_accessor :verbose
|
8
|
+
@verbose = false
|
9
|
+
|
10
|
+
attr_accessor :running_git_hook
|
11
|
+
@running_git_hook = false
|
12
|
+
end
|
13
13
|
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
require "securerandom"
|
2
|
-
|
3
|
-
require "multirepo/utility/console"
|
4
|
-
require "multirepo/git/repo"
|
5
|
-
|
6
|
-
module MultiRepo
|
7
|
-
class ConfigEntry
|
8
|
-
attr_accessor :id
|
9
|
-
attr_accessor :path
|
10
|
-
attr_accessor :url
|
11
|
-
attr_accessor :branch
|
12
|
-
attr_accessor :repo
|
13
|
-
|
14
|
-
def encode_with(coder)
|
15
|
-
coder["id"] = @id
|
16
|
-
coder["path"] = @path
|
17
|
-
coder["url"] = @url
|
18
|
-
coder["branch"] = @branch
|
19
|
-
end
|
20
|
-
|
21
|
-
def ==(entry)
|
22
|
-
entry_path = Pathname.new(entry.path)
|
23
|
-
self_path = Pathname.new(self.path)
|
24
|
-
entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize(repo)
|
28
|
-
@id = SecureRandom.uuid
|
29
|
-
@path = repo.path
|
30
|
-
@url = repo.exists? ? repo.remote('origin').url : nil
|
31
|
-
@branch = repo.exists? ? repo.current_branch : nil
|
32
|
-
end
|
33
|
-
|
34
|
-
def repo
|
35
|
-
Repo.new(path)
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require "securerandom"
|
2
|
+
|
3
|
+
require "multirepo/utility/console"
|
4
|
+
require "multirepo/git/repo"
|
5
|
+
|
6
|
+
module MultiRepo
|
7
|
+
class ConfigEntry
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :path
|
10
|
+
attr_accessor :url
|
11
|
+
attr_accessor :branch
|
12
|
+
attr_accessor :repo
|
13
|
+
|
14
|
+
def encode_with(coder)
|
15
|
+
coder["id"] = @id
|
16
|
+
coder["path"] = @path
|
17
|
+
coder["url"] = @url
|
18
|
+
coder["branch"] = @branch
|
19
|
+
end
|
20
|
+
|
21
|
+
def ==(entry)
|
22
|
+
entry_path = Pathname.new(entry.path)
|
23
|
+
self_path = Pathname.new(self.path)
|
24
|
+
entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(repo)
|
28
|
+
@id = SecureRandom.uuid
|
29
|
+
@path = repo.path
|
30
|
+
@url = repo.exists? ? repo.remote('origin').url : nil
|
31
|
+
@branch = repo.exists? ? repo.current_branch : nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def repo
|
35
|
+
Repo.new(path)
|
36
|
+
end
|
37
|
+
end
|
38
38
|
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
require "pathname"
|
3
|
-
|
4
|
-
require_relative "config-entry"
|
5
|
-
|
6
|
-
module MultiRepo
|
7
|
-
class ConfigFile
|
8
|
-
FILE = Pathname.new(".multirepo")
|
9
|
-
|
10
|
-
def self.exists?
|
11
|
-
FILE.exist?
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.load
|
15
|
-
Psych.load(FILE.read)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.save(entries)
|
19
|
-
File.write(FILE.to_s, Psych.dump(entries))
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.entry_exists?(entry)
|
23
|
-
load.any? { |e| e == entry }
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.add_entry(entry)
|
27
|
-
save(load.push(entry))
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.remove_entry(entry)
|
31
|
-
save(load.delete_if { |e| e == entry })
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.stage
|
35
|
-
Git.run_in_current_dir("add -A -f #{FILE.to_s}", Runner::Verbosity::NEVER_OUTPUT)
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
require_relative "config-entry"
|
5
|
+
|
6
|
+
module MultiRepo
|
7
|
+
class ConfigFile
|
8
|
+
FILE = Pathname.new(".multirepo")
|
9
|
+
|
10
|
+
def self.exists?
|
11
|
+
FILE.exist?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.load
|
15
|
+
Psych.load(FILE.read)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.save(entries)
|
19
|
+
File.write(FILE.to_s, Psych.dump(entries))
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.entry_exists?(entry)
|
23
|
+
load.any? { |e| e == entry }
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.add_entry(entry)
|
27
|
+
save(load.push(entry))
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.remove_entry(entry)
|
31
|
+
save(load.delete_if { |e| e == entry })
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.stage
|
35
|
+
Git.run_in_current_dir("add -A -f #{FILE.to_s}", Runner::Verbosity::NEVER_OUTPUT)
|
36
|
+
end
|
37
|
+
end
|
38
38
|
end
|