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,22 +1,22 @@
|
|
1
|
-
require "os"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class EditCommand < Command
|
5
|
-
self.command = "edit"
|
6
|
-
self.summary = "Opens the .multirepo file in the default text editor."
|
7
|
-
|
8
|
-
def run
|
9
|
-
super
|
10
|
-
ensure_multirepo_initialized
|
11
|
-
|
12
|
-
if OS.posix?
|
13
|
-
editor = `echo ${FCEDIT:-${VISUAL:-${EDITOR:-vi}}}`.strip
|
14
|
-
system(editor, ".multirepo")
|
15
|
-
elsif OS.windows?
|
16
|
-
raise MultiRepoException, "The edit command is not implemented on Window yet."
|
17
|
-
end
|
18
|
-
rescue MultiRepoException => e
|
19
|
-
Console.log_error(e.message)
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require "os"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class EditCommand < Command
|
5
|
+
self.command = "edit"
|
6
|
+
self.summary = "Opens the .multirepo file in the default text editor."
|
7
|
+
|
8
|
+
def run
|
9
|
+
super
|
10
|
+
ensure_multirepo_initialized
|
11
|
+
|
12
|
+
if OS.posix?
|
13
|
+
editor = `echo ${FCEDIT:-${VISUAL:-${EDITOR:-vi}}}`.strip
|
14
|
+
system(editor, ".multirepo")
|
15
|
+
elsif OS.windows?
|
16
|
+
raise MultiRepoException, "The edit command is not implemented on Window yet."
|
17
|
+
end
|
18
|
+
rescue MultiRepoException => e
|
19
|
+
Console.log_error(e.message)
|
20
|
+
end
|
21
|
+
end
|
22
22
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
|
3
|
-
module MultiRepo
|
4
|
-
class FetchCommand < Command
|
5
|
-
self.command = "fetch"
|
6
|
-
self.summary = "Performs a git fetch on all dependencies."
|
7
|
-
|
8
|
-
def run
|
9
|
-
super
|
10
|
-
ensure_multirepo_initialized
|
11
|
-
|
12
|
-
Console.log_step("Fetching dependencies...")
|
13
|
-
|
14
|
-
ConfigFile.load.each do |entry|
|
15
|
-
Console.log_substep("Fetching from #{entry.repo.remote('origin').url}...")
|
16
|
-
entry.repo.fetch
|
17
|
-
end
|
18
|
-
|
19
|
-
Console.log_step("Done!")
|
20
|
-
rescue MultiRepoException => e
|
21
|
-
Console.log_error(e.message)
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
|
3
|
+
module MultiRepo
|
4
|
+
class FetchCommand < Command
|
5
|
+
self.command = "fetch"
|
6
|
+
self.summary = "Performs a git fetch on all dependencies."
|
7
|
+
|
8
|
+
def run
|
9
|
+
super
|
10
|
+
ensure_multirepo_initialized
|
11
|
+
|
12
|
+
Console.log_step("Fetching dependencies...")
|
13
|
+
|
14
|
+
ConfigFile.load.each do |entry|
|
15
|
+
Console.log_substep("Fetching from #{entry.repo.remote('origin').url}...")
|
16
|
+
entry.repo.fetch
|
17
|
+
end
|
18
|
+
|
19
|
+
Console.log_step("Done!")
|
20
|
+
rescue MultiRepoException => e
|
21
|
+
Console.log_error(e.message)
|
22
|
+
end
|
23
|
+
end
|
24
24
|
end
|
@@ -1,54 +1,54 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
require "multirepo/utility/utils"
|
3
|
-
require "multirepo/files/config-file"
|
4
|
-
require "multirepo/files/lock-file"
|
5
|
-
require "multirepo/commands/command"
|
6
|
-
|
7
|
-
module MultiRepo
|
8
|
-
class InitCommand < Command
|
9
|
-
self.command = "init"
|
10
|
-
self.summary = "Initialize the current repository as a multirepo project."
|
11
|
-
|
12
|
-
def run
|
13
|
-
super
|
14
|
-
Console.log_step("Initializing new multirepo config...")
|
15
|
-
|
16
|
-
if ConfigFile.exists?
|
17
|
-
return unless Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
|
18
|
-
end
|
19
|
-
|
20
|
-
sibling_repos = Utils.sibling_repos
|
21
|
-
|
22
|
-
if sibling_repos.any?
|
23
|
-
entries = []
|
24
|
-
sibling_repos.each do |repo|
|
25
|
-
if Console.ask_yes_no("Do you want to add '#{repo.path}' (#{repo.remote('origin').url} #{repo.current_branch}) as a dependency?")
|
26
|
-
entries.push(ConfigEntry.new(repo))
|
27
|
-
Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
ConfigFile.save(entries)
|
32
|
-
ConfigFile.stage
|
33
|
-
|
34
|
-
|
35
|
-
raise MultiRepoException, "Can't finish initialization!"
|
36
|
-
|
37
|
-
self.update_lock_file
|
38
|
-
else
|
39
|
-
Console.log_info("There are no sibling repositories to add")
|
40
|
-
end
|
41
|
-
|
42
|
-
self.install_pre_commit_hook
|
43
|
-
|
44
|
-
Console.log_step("Done!")
|
45
|
-
rescue MultiRepoException => e
|
46
|
-
Console.log_error(e.message)
|
47
|
-
end
|
48
|
-
|
49
|
-
def check_repo_exists
|
50
|
-
if !Dir.exists?(@repo.path) then raise MultiRepoException, "There is no folder at path '#{@repo.path}'" end
|
51
|
-
if !@repo.exists? then raise MultiRepoException, "'#{@repo.path}' is not a repository" end
|
52
|
-
end
|
53
|
-
end
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
require "multirepo/utility/utils"
|
3
|
+
require "multirepo/files/config-file"
|
4
|
+
require "multirepo/files/lock-file"
|
5
|
+
require "multirepo/commands/command"
|
6
|
+
|
7
|
+
module MultiRepo
|
8
|
+
class InitCommand < Command
|
9
|
+
self.command = "init"
|
10
|
+
self.summary = "Initialize the current repository as a multirepo project."
|
11
|
+
|
12
|
+
def run
|
13
|
+
super
|
14
|
+
Console.log_step("Initializing new multirepo config...")
|
15
|
+
|
16
|
+
if ConfigFile.exists?
|
17
|
+
return unless Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
|
18
|
+
end
|
19
|
+
|
20
|
+
sibling_repos = Utils.sibling_repos
|
21
|
+
|
22
|
+
if sibling_repos.any?
|
23
|
+
entries = []
|
24
|
+
sibling_repos.each do |repo|
|
25
|
+
if Console.ask_yes_no("Do you want to add '#{repo.path}' (#{repo.remote('origin').url} #{repo.current_branch}) as a dependency?")
|
26
|
+
entries.push(ConfigEntry.new(repo))
|
27
|
+
Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
ConfigFile.save(entries)
|
32
|
+
ConfigFile.stage
|
33
|
+
|
34
|
+
dependencies_clean = Utils.ensure_dependencies_clean(entries)
|
35
|
+
raise MultiRepoException, "Can't finish initialization!" unless dependencies_clean
|
36
|
+
|
37
|
+
self.update_lock_file
|
38
|
+
else
|
39
|
+
Console.log_info("There are no sibling repositories to add")
|
40
|
+
end
|
41
|
+
|
42
|
+
self.install_pre_commit_hook
|
43
|
+
|
44
|
+
Console.log_step("Done!")
|
45
|
+
rescue MultiRepoException => e
|
46
|
+
Console.log_error(e.message)
|
47
|
+
end
|
48
|
+
|
49
|
+
def check_repo_exists
|
50
|
+
if !Dir.exists?(@repo.path) then raise MultiRepoException, "There is no folder at path '#{@repo.path}'" end
|
51
|
+
if !@repo.exists? then raise MultiRepoException, "'#{@repo.path}' is not a repository" end
|
52
|
+
end
|
53
|
+
end
|
54
54
|
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
require "multirepo/utility/console"
|
2
|
-
require "multirepo/utility/utils"
|
3
|
-
require "multirepo/git/repo"
|
4
|
-
|
5
|
-
module MultiRepo
|
6
|
-
class InstallCommand < Command
|
7
|
-
self.command = "install"
|
8
|
-
self.summary = "Clones and checks out dependencies as defined in the .multirepo file, and installs git-multirepo's local pre-commit hook."
|
9
|
-
|
10
|
-
def run
|
11
|
-
super
|
12
|
-
ensure_multirepo_initialized
|
13
|
-
|
14
|
-
Console.log_step("Cloning dependencies and installing hook...")
|
15
|
-
|
16
|
-
config_entries = ConfigFile.load
|
17
|
-
|
18
|
-
Console.log_info("There are #{config_entries.count} dependencies to install");
|
19
|
-
|
20
|
-
config_entries.each { |e| install(e) }
|
21
|
-
|
22
|
-
self.install_pre_commit_hook
|
23
|
-
|
24
|
-
Console.log_step("Done!")
|
25
|
-
rescue MultiRepoException => e
|
26
|
-
Console.log_error(e.message)
|
27
|
-
end
|
28
|
-
|
29
|
-
def install(entry)
|
30
|
-
if entry.repo.exists?
|
31
|
-
check_repo_validity(entry)
|
32
|
-
fetch_repo(entry)
|
33
|
-
else
|
34
|
-
clone_repo(entry)
|
35
|
-
end
|
36
|
-
checkout_branch(entry)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Repo operations
|
40
|
-
|
41
|
-
def fetch_repo(entry)
|
42
|
-
Console.log_substep("Working copy '#{entry.repo.path}' already exists, fetching instead...")
|
43
|
-
raise MultiRepoException, "Could not fetch from remote #{entry.repo.remote('origin').url}" unless entry.repo.fetch
|
44
|
-
end
|
45
|
-
|
46
|
-
def clone_repo(entry)
|
47
|
-
Console.log_substep("Cloning '#{entry.url} to #{entry.repo.path}'")
|
48
|
-
raise MultiRepoException, "Could not clone remote #{entry.url}" unless entry.repo.clone(entry.url)
|
49
|
-
end
|
50
|
-
|
51
|
-
def checkout_branch(entry)
|
52
|
-
branch = entry.repo.branch(entry.branch);
|
53
|
-
raise MultiRepoException, "Could not checkout branch #{branch.name}" unless branch.checkout
|
54
|
-
Console.log_substep("Checked out branch #{branch.name} -> origin/#{branch.name}")
|
55
|
-
end
|
56
|
-
|
57
|
-
# Validation
|
58
|
-
|
59
|
-
def check_repo_validity(entry)
|
60
|
-
unless entry.repo.remote("origin").url == entry.url
|
61
|
-
raise MultiRepoException, "'#{entry.path}' origin URL (#{entry.repo.remote('origin').url}) does not match entry (#{entry.url})!"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
1
|
+
require "multirepo/utility/console"
|
2
|
+
require "multirepo/utility/utils"
|
3
|
+
require "multirepo/git/repo"
|
4
|
+
|
5
|
+
module MultiRepo
|
6
|
+
class InstallCommand < Command
|
7
|
+
self.command = "install"
|
8
|
+
self.summary = "Clones and checks out dependencies as defined in the .multirepo file, and installs git-multirepo's local pre-commit hook."
|
9
|
+
|
10
|
+
def run
|
11
|
+
super
|
12
|
+
ensure_multirepo_initialized
|
13
|
+
|
14
|
+
Console.log_step("Cloning dependencies and installing hook...")
|
15
|
+
|
16
|
+
config_entries = ConfigFile.load
|
17
|
+
|
18
|
+
Console.log_info("There are #{config_entries.count} dependencies to install");
|
19
|
+
|
20
|
+
config_entries.each { |e| install(e) }
|
21
|
+
|
22
|
+
self.install_pre_commit_hook
|
23
|
+
|
24
|
+
Console.log_step("Done!")
|
25
|
+
rescue MultiRepoException => e
|
26
|
+
Console.log_error(e.message)
|
27
|
+
end
|
28
|
+
|
29
|
+
def install(entry)
|
30
|
+
if entry.repo.exists?
|
31
|
+
check_repo_validity(entry)
|
32
|
+
fetch_repo(entry)
|
33
|
+
else
|
34
|
+
clone_repo(entry)
|
35
|
+
end
|
36
|
+
checkout_branch(entry)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Repo operations
|
40
|
+
|
41
|
+
def fetch_repo(entry)
|
42
|
+
Console.log_substep("Working copy '#{entry.repo.path}' already exists, fetching instead...")
|
43
|
+
raise MultiRepoException, "Could not fetch from remote #{entry.repo.remote('origin').url}" unless entry.repo.fetch
|
44
|
+
end
|
45
|
+
|
46
|
+
def clone_repo(entry)
|
47
|
+
Console.log_substep("Cloning '#{entry.url} to #{entry.repo.path}'")
|
48
|
+
raise MultiRepoException, "Could not clone remote #{entry.url}" unless entry.repo.clone(entry.url)
|
49
|
+
end
|
50
|
+
|
51
|
+
def checkout_branch(entry)
|
52
|
+
branch = entry.repo.branch(entry.branch);
|
53
|
+
raise MultiRepoException, "Could not checkout branch #{branch.name}" unless branch.checkout
|
54
|
+
Console.log_substep("Checked out branch #{branch.name} -> origin/#{branch.name}")
|
55
|
+
end
|
56
|
+
|
57
|
+
# Validation
|
58
|
+
|
59
|
+
def check_repo_validity(entry)
|
60
|
+
unless entry.repo.remote("origin").url == entry.url
|
61
|
+
raise MultiRepoException, "'#{entry.path}' origin URL (#{entry.repo.remote('origin').url}) does not match entry (#{entry.url})!"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
65
|
end
|
@@ -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
|
-
super
|
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
|
+
super
|
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,42 +1,42 @@
|
|
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 initialize(argv)
|
10
|
-
@path = argv.shift_argument
|
11
|
-
@delete = argv.flag?("delete")
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate!
|
16
|
-
super
|
17
|
-
help! "You must specify a dependency repository to remove" unless @path
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
super
|
22
|
-
ensure_multirepo_initialized
|
23
|
-
|
24
|
-
repo = Repo.new(@path)
|
25
|
-
entry = ConfigEntry.new(repo)
|
26
|
-
|
27
|
-
if ConfigFile.entry_exists?(entry)
|
28
|
-
ConfigFile.remove_entry(entry)
|
29
|
-
Console.log_step("Removed '#{@path}' from the .multirepo file")
|
30
|
-
|
31
|
-
if @delete
|
32
|
-
FileUtils.rm_rf(@path)
|
33
|
-
Console.log_step("Deleted '#{@path}' from disk")
|
34
|
-
end
|
35
|
-
else
|
36
|
-
raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
|
37
|
-
end
|
38
|
-
rescue MultiRepoException => e
|
39
|
-
Console.log_error(e.message)
|
40
|
-
end
|
41
|
-
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 initialize(argv)
|
10
|
+
@path = argv.shift_argument
|
11
|
+
@delete = argv.flag?("delete")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate!
|
16
|
+
super
|
17
|
+
help! "You must specify a dependency repository to remove" unless @path
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
super
|
22
|
+
ensure_multirepo_initialized
|
23
|
+
|
24
|
+
repo = Repo.new(@path)
|
25
|
+
entry = ConfigEntry.new(repo)
|
26
|
+
|
27
|
+
if ConfigFile.entry_exists?(entry)
|
28
|
+
ConfigFile.remove_entry(entry)
|
29
|
+
Console.log_step("Removed '#{@path}' from the .multirepo file")
|
30
|
+
|
31
|
+
if @delete
|
32
|
+
FileUtils.rm_rf(@path)
|
33
|
+
Console.log_step("Deleted '#{@path}' from disk")
|
34
|
+
end
|
35
|
+
else
|
36
|
+
raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
|
37
|
+
end
|
38
|
+
rescue MultiRepoException => e
|
39
|
+
Console.log_error(e.message)
|
40
|
+
end
|
41
|
+
end
|
42
42
|
end
|