git-multirepo 1.0.0.beta9 → 1.0.0.beta10
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 +136 -136
- data/Rakefile +2 -2
- data/bin/multi +5 -5
- data/git-multirepo.gemspec +29 -29
- data/lib/commands.rb +11 -11
- data/lib/info.rb +4 -4
- data/lib/multirepo/commands/add-command.rb +40 -40
- data/lib/multirepo/commands/branch-command.rb +43 -50
- data/lib/multirepo/commands/checkout-command.rb +66 -66
- data/lib/multirepo/commands/command.rb +40 -40
- 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 +64 -64
- data/lib/multirepo/commands/open-command.rb +25 -25
- data/lib/multirepo/commands/remove-command.rb +41 -41
- data/lib/multirepo/commands/uninit-command.rb +20 -20
- data/lib/multirepo/commands/update-command.rb +43 -33
- 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 +38 -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/pre-commit-hook.rb +23 -24
- data/lib/multirepo/multirepo-exception.rb +5 -5
- data/lib/multirepo/utility/console.rb +51 -51
- data/lib/multirepo/utility/runner.rb +20 -20
- data/lib/multirepo/utility/utils.rb +41 -36
- data/resources/pre-commit +5 -5
- data/spec/integration/init_spec.rb +22 -22
- data/spec/spec_helper.rb +89 -89
- metadata +23 -23
@@ -1,21 +1,21 @@
|
|
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
|
-
super
|
10
|
-
ensure_multirepo_initialized
|
11
|
-
|
12
|
-
File.delete(".multirepo")
|
13
|
-
File.delete(".multirepo.lock")
|
14
|
-
File.delete(".git/hooks/pre-commit")
|
15
|
-
|
16
|
-
Console.log_step("All traces of multirepo have been removed from this repository")
|
17
|
-
rescue MultiRepoException => e
|
18
|
-
Console.log_error(e.message)
|
19
|
-
end
|
20
|
-
end
|
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
|
+
super
|
10
|
+
ensure_multirepo_initialized
|
11
|
+
|
12
|
+
File.delete(".multirepo")
|
13
|
+
File.delete(".multirepo.lock")
|
14
|
+
File.delete(".git/hooks/pre-commit")
|
15
|
+
|
16
|
+
Console.log_step("All traces of multirepo have been removed from this repository")
|
17
|
+
rescue MultiRepoException => e
|
18
|
+
Console.log_error(e.message)
|
19
|
+
end
|
20
|
+
end
|
21
21
|
end
|
@@ -1,34 +1,44 @@
|
|
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 initialize(argv)
|
9
|
-
@commit = argv.flag?("commit")
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
LockFile.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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 initialize(argv)
|
9
|
+
@commit = argv.flag?("commit")
|
10
|
+
@force = argv.flag?("force")
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
super
|
16
|
+
ensure_multirepo_initialized
|
17
|
+
|
18
|
+
Console.log_step("Updating...")
|
19
|
+
|
20
|
+
dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
|
21
|
+
|
22
|
+
if dependencies_clean
|
23
|
+
LockFile.update
|
24
|
+
Console.log_substep("Updated lock file with latest dependency commits")
|
25
|
+
elsif !dependencies_clean && @force
|
26
|
+
LockFile.update
|
27
|
+
Console.log_warning("Updated lock file with latest dependency commits regardless of uncommitted changes")
|
28
|
+
else
|
29
|
+
raise MultiRepoException, "Can't update because not all dependencies are clean"
|
30
|
+
end
|
31
|
+
|
32
|
+
self.install_pre_commit_hook
|
33
|
+
|
34
|
+
if @commit
|
35
|
+
Console.log_substep("Committing updated lock file")
|
36
|
+
LockFile.commit
|
37
|
+
end
|
38
|
+
|
39
|
+
Console.log_step("Done!")
|
40
|
+
rescue MultiRepoException => e
|
41
|
+
Console.log_error(e.message)
|
42
|
+
end
|
43
|
+
end
|
34
44
|
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}", false)
|
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}", false)
|
36
|
+
end
|
37
|
+
end
|
38
38
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
require "multirepo/git/repo"
|
3
|
-
|
4
|
-
module MultiRepo
|
5
|
-
class LockEntry
|
6
|
-
attr_accessor :config_entry
|
7
|
-
attr_accessor :name
|
8
|
-
attr_accessor :id
|
9
|
-
attr_accessor :head
|
10
|
-
attr_accessor :branch
|
11
|
-
|
12
|
-
def encode_with(coder)
|
13
|
-
coder["name"] = @name
|
14
|
-
coder["id"] = @id
|
15
|
-
coder["head"] = @head
|
16
|
-
coder["branch"] = @branch
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize(config_entry)
|
20
|
-
@name = config_entry.repo.basename
|
21
|
-
@id = config_entry.id
|
22
|
-
@head = config_entry.repo.head_hash
|
23
|
-
@branch = config_entry.repo.current_branch
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
require "multirepo/git/repo"
|
3
|
+
|
4
|
+
module MultiRepo
|
5
|
+
class LockEntry
|
6
|
+
attr_accessor :config_entry
|
7
|
+
attr_accessor :name
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :head
|
10
|
+
attr_accessor :branch
|
11
|
+
|
12
|
+
def encode_with(coder)
|
13
|
+
coder["name"] = @name
|
14
|
+
coder["id"] = @id
|
15
|
+
coder["head"] = @head
|
16
|
+
coder["branch"] = @branch
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(config_entry)
|
20
|
+
@name = config_entry.repo.basename
|
21
|
+
@id = config_entry.id
|
22
|
+
@head = config_entry.repo.head_hash
|
23
|
+
@branch = config_entry.repo.current_branch
|
24
|
+
end
|
25
|
+
end
|
26
26
|
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
require "pathname"
|
2
|
-
require "psych"
|
3
|
-
|
4
|
-
require "multirepo/git/git"
|
5
|
-
require_relative "lock-entry"
|
6
|
-
require_relative "config-file"
|
7
|
-
|
8
|
-
module MultiRepo
|
9
|
-
class LockFile
|
10
|
-
FILE = Pathname.new(".multirepo.lock")
|
11
|
-
|
12
|
-
def self.exists?
|
13
|
-
FILE.exist?
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.load
|
17
|
-
Psych.load(FILE.read)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.update
|
21
|
-
config_entries = ConfigFile.load
|
22
|
-
lock_entries = config_entries.map { |c| LockEntry.new(c) }
|
23
|
-
|
24
|
-
File.write(FILE.to_s, Psych.dump(lock_entries))
|
25
|
-
|
26
|
-
Git.run_in_current_dir("add -A #{FILE.to_s}", false)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.commit
|
30
|
-
Git.run_in_current_dir("commit -m \"Updated multirepo lock file with the latest version of all dependencies\" -o -- #{FILE.to_s}", false)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.validate_components(line, components)
|
34
|
-
unless components.count == 2
|
35
|
-
raise MultiRepoException, "Wrong entry format in .multirepo.lock file: #{line}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
require "pathname"
|
2
|
+
require "psych"
|
3
|
+
|
4
|
+
require "multirepo/git/git"
|
5
|
+
require_relative "lock-entry"
|
6
|
+
require_relative "config-file"
|
7
|
+
|
8
|
+
module MultiRepo
|
9
|
+
class LockFile
|
10
|
+
FILE = Pathname.new(".multirepo.lock")
|
11
|
+
|
12
|
+
def self.exists?
|
13
|
+
FILE.exist?
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load
|
17
|
+
Psych.load(FILE.read)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.update
|
21
|
+
config_entries = ConfigFile.load
|
22
|
+
lock_entries = config_entries.map { |c| LockEntry.new(c) }
|
23
|
+
|
24
|
+
File.write(FILE.to_s, Psych.dump(lock_entries))
|
25
|
+
|
26
|
+
Git.run_in_current_dir("add -A #{FILE.to_s}", false)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.commit
|
30
|
+
Git.run_in_current_dir("commit -m \"Updated multirepo lock file with the latest version of all dependencies\" -o -- #{FILE.to_s}", false)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.validate_components(line, components)
|
34
|
+
unless components.count == 2
|
35
|
+
raise MultiRepoException, "Wrong entry format in .multirepo.lock file: #{line}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
39
|
end
|
data/lib/multirepo/git/branch.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
require_relative "git"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class Branch
|
5
|
-
attr_accessor :name
|
6
|
-
|
7
|
-
def initialize(repo, name)
|
8
|
-
@repo = repo
|
9
|
-
@name = name
|
10
|
-
end
|
11
|
-
|
12
|
-
def exists?
|
13
|
-
lines = Git.run_in_working_dir(@repo.path, "branch", false).split("\n")
|
14
|
-
branch_names = lines.map { |line| line.tr("* ", "")}
|
15
|
-
branch_names.include?(@name)
|
16
|
-
end
|
17
|
-
|
18
|
-
def create(remote_tracking = false)
|
19
|
-
Git.run_in_working_dir(@repo.path, "branch #{@name}", false)
|
20
|
-
Git.run_in_working_dir(@repo.path, "push -u origin #{name}", false) if remote_tracking
|
21
|
-
end
|
22
|
-
|
23
|
-
def checkout
|
24
|
-
Git.run_in_working_dir(@repo.path, "checkout #{@name}", false)
|
25
|
-
Git.last_command_succeeded
|
26
|
-
end
|
27
|
-
end
|
1
|
+
require_relative "git"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class Branch
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
def initialize(repo, name)
|
8
|
+
@repo = repo
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def exists?
|
13
|
+
lines = Git.run_in_working_dir(@repo.path, "branch", false).split("\n")
|
14
|
+
branch_names = lines.map { |line| line.tr("* ", "")}
|
15
|
+
branch_names.include?(@name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(remote_tracking = false)
|
19
|
+
Git.run_in_working_dir(@repo.path, "branch #{@name}", false)
|
20
|
+
Git.run_in_working_dir(@repo.path, "push -u origin #{name}", false) if remote_tracking
|
21
|
+
end
|
22
|
+
|
23
|
+
def checkout
|
24
|
+
Git.run_in_working_dir(@repo.path, "checkout #{@name}", false)
|
25
|
+
Git.last_command_succeeded
|
26
|
+
end
|
27
|
+
end
|
28
28
|
end
|