git-multirepo 1.0.0.beta45 → 1.0.0.beta46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -2
  3. data/.gitbugtraq +3 -3
  4. data/.gitignore +38 -38
  5. data/.multirepo +21 -21
  6. data/.multirepo.lock +26 -26
  7. data/.multirepo.meta +2 -2
  8. data/.rspec +2 -2
  9. data/Gemfile +4 -4
  10. data/Gemfile.lock +42 -42
  11. data/LICENSE +22 -22
  12. data/README.md +154 -144
  13. data/Rakefile +2 -2
  14. data/bin/multi +10 -10
  15. data/docs/bug-repros/91565510-repro.sh +20 -20
  16. data/docs/git-multirepo-cheatsheet.docx +0 -0
  17. data/git-multirepo.gemspec +31 -31
  18. data/lib/commands.rb +14 -14
  19. data/lib/git-multirepo.rb +2 -2
  20. data/lib/info.rb +4 -4
  21. data/lib/multirepo/commands/add-command.rb +50 -50
  22. data/lib/multirepo/commands/branch-command.rb +81 -81
  23. data/lib/multirepo/commands/checkout-command.rb +119 -119
  24. data/lib/multirepo/commands/clone-command.rb +67 -67
  25. data/lib/multirepo/commands/command.rb +89 -89
  26. data/lib/multirepo/commands/do-command.rb +102 -100
  27. data/lib/multirepo/commands/graph-command.rb +42 -42
  28. data/lib/multirepo/commands/init-command.rb +119 -119
  29. data/lib/multirepo/commands/inspect-command.rb +38 -39
  30. data/lib/multirepo/commands/install-command.rb +146 -137
  31. data/lib/multirepo/commands/merge-command.rb +225 -225
  32. data/lib/multirepo/commands/open-command.rb +56 -55
  33. data/lib/multirepo/commands/remove-command.rb +47 -47
  34. data/lib/multirepo/commands/uninit-command.rb +17 -17
  35. data/lib/multirepo/commands/update-command.rb +55 -55
  36. data/lib/multirepo/config.rb +15 -15
  37. data/lib/multirepo/files/config-entry.rb +38 -38
  38. data/lib/multirepo/files/config-file.rb +45 -45
  39. data/lib/multirepo/files/lock-entry.rb +28 -28
  40. data/lib/multirepo/files/lock-file.rb +55 -55
  41. data/lib/multirepo/files/meta-file.rb +40 -40
  42. data/lib/multirepo/files/tracking-file.rb +8 -8
  43. data/lib/multirepo/files/tracking-files.rb +46 -46
  44. data/lib/multirepo/git/branch.rb +31 -31
  45. data/lib/multirepo/git/change.rb +10 -10
  46. data/lib/multirepo/git/commit.rb +6 -6
  47. data/lib/multirepo/git/git-runner.rb +46 -46
  48. data/lib/multirepo/git/git.rb +9 -9
  49. data/lib/multirepo/git/ref.rb +37 -37
  50. data/lib/multirepo/git/remote.rb +16 -16
  51. data/lib/multirepo/git/repo.rb +122 -122
  52. data/lib/multirepo/hooks/post-commit-hook.rb +22 -22
  53. data/lib/multirepo/hooks/pre-commit-hook.rb +34 -34
  54. data/lib/multirepo/logic/dependency.rb +5 -5
  55. data/lib/multirepo/logic/merge-descriptor.rb +94 -94
  56. data/lib/multirepo/logic/node.rb +71 -71
  57. data/lib/multirepo/logic/performer.rb +56 -56
  58. data/lib/multirepo/logic/revision-selector.rb +34 -34
  59. data/lib/multirepo/multirepo-exception.rb +5 -5
  60. data/lib/multirepo/utility/console.rb +51 -51
  61. data/lib/multirepo/utility/runner.rb +34 -34
  62. data/lib/multirepo/utility/utils.rb +94 -94
  63. data/resources/.gitconfig +2 -2
  64. data/resources/post-commit +5 -5
  65. data/resources/pre-commit +5 -5
  66. data/spec/integration/init_spec.rb +18 -18
  67. data/spec/spec_helper.rb +89 -89
  68. metadata +2 -2
@@ -1,120 +1,120 @@
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/files/tracking-files"
6
- require "multirepo/commands/command"
7
-
8
- module MultiRepo
9
- class InitCommand < Command
10
- self.command = "init"
11
- self.summary = "Initialize the current repository as a multirepo project."
12
-
13
- def self.options
14
- [['[--extras]', 'Keep the current .multirepo config file as-is and initialize everything else.']].concat(super)
15
- end
16
-
17
- def initialize(argv)
18
- @only_extras = argv.flag?("extras")
19
- super
20
- end
21
-
22
- def run
23
- ensure_in_work_tree
24
-
25
- if @only_extras
26
- ensure_multirepo_enabled
27
- Console.log_step("Initializing extras...")
28
- initialize_extras_step
29
- else
30
- Console.log_step("Initializing multirepo...")
31
- full_initialize_step
32
- end
33
-
34
- Console.log_step("Done!")
35
- end
36
-
37
- def full_initialize_step
38
- if ConfigFile.new(".").exists?
39
- reinitialize = Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
40
- raise MultiRepoException, "Initialization aborted" unless reinitialize
41
- end
42
-
43
- unless add_sibling_repos_step
44
- raise MultiRepoException, "There are no sibling repositories to track as dependencies. Initialization aborted."
45
- end
46
-
47
- initialize_extras_step
48
- end
49
-
50
- def add_sibling_repos_step
51
- sibling_repos = Utils.sibling_repos
52
- return false unless sibling_repos.any?
53
-
54
- Console.log_substep("Creating new multirepo config...")
55
-
56
- valid_repos = find_valid_repos(sibling_repos)
57
- entries = create_entries(valid_repos)
58
-
59
- raise MultiRepoException, "No sibling repositories were added as dependencies; init aborted" unless entries.any?
60
-
61
- ConfigFile.new(".").save_entries(entries)
62
- return true
63
- end
64
-
65
- def initialize_extras_step
66
- install_hooks_step
67
- update_gitattributes_step
68
- update_gitconfig_step
69
- end
70
-
71
- def install_hooks_step
72
- install_hooks(".")
73
- Console.log_substep("Installed git hooks")
74
- end
75
-
76
- def update_gitattributes_step
77
- TrackingFiles.new(".").files.each do |f|
78
- filename = f.filename
79
- regex_escaped_filename = Regexp.quote(filename)
80
- Utils.append_if_missing("./.gitattributes", /^#{regex_escaped_filename} .*/, "#{filename} merge=ours")
81
- end
82
- Console.log_substep("Updated .gitattributes file")
83
- end
84
-
85
- def update_gitconfig_step
86
- update_gitconfig(".")
87
- Console.log_substep("Updated .git/config file")
88
- end
89
-
90
- def find_valid_repos(repos)
91
- repos.select do |repo|
92
- next true if repo.head_born?
93
- Console.log_warning("Ignoring repo '#{repo.path}' because its HEAD is unborn. You must perform at least one commit.")
94
- end
95
- end
96
-
97
- def create_entries(repos)
98
- entries = []
99
- repos.each do |repo|
100
- origin_url = repo.remote('origin').url
101
- current_branch_name = repo.current_branch.name
102
-
103
- if Console.ask_yes_no("Do you want to add '#{repo.path}' as a dependency?\n [origin: #{origin_url || "NONE"}, branch: #{current_branch_name}]")
104
- unless origin_url
105
- Console.log_warning("Repo 'origin' remote url is not set; skipping")
106
- next
107
- end
108
- entries.push(ConfigEntry.new(repo))
109
- Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
110
- end
111
- end
112
- return entries
113
- end
114
-
115
- def check_repo_exists
116
- raise MultiRepoException, "There is no folder at path '#{@repo.path}'" unless Dir.exists?(@repo.path)
117
- raise MultiRepoException, "'#{@repo.path}' is not a repository" unless @repo.exists?
118
- end
119
- 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/files/tracking-files"
6
+ require "multirepo/commands/command"
7
+
8
+ module MultiRepo
9
+ class InitCommand < Command
10
+ self.command = "init"
11
+ self.summary = "Initialize the current repository as a multirepo project."
12
+
13
+ def self.options
14
+ [['[--extras]', 'Keep the current .multirepo config file as-is and initialize everything else.']].concat(super)
15
+ end
16
+
17
+ def initialize(argv)
18
+ @only_extras = argv.flag?("extras")
19
+ super
20
+ end
21
+
22
+ def run
23
+ ensure_in_work_tree
24
+
25
+ if @only_extras
26
+ ensure_multirepo_enabled
27
+ Console.log_step("Initializing extras...")
28
+ initialize_extras_step
29
+ else
30
+ Console.log_step("Initializing multirepo...")
31
+ full_initialize_step
32
+ end
33
+
34
+ Console.log_step("Done!")
35
+ end
36
+
37
+ def full_initialize_step
38
+ if ConfigFile.new(".").exists?
39
+ reinitialize = Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
40
+ raise MultiRepoException, "Initialization aborted" unless reinitialize
41
+ end
42
+
43
+ unless add_sibling_repos_step
44
+ raise MultiRepoException, "There are no sibling repositories to track as dependencies. Initialization aborted."
45
+ end
46
+
47
+ initialize_extras_step
48
+ end
49
+
50
+ def add_sibling_repos_step
51
+ sibling_repos = Utils.sibling_repos
52
+ return false unless sibling_repos.any?
53
+
54
+ Console.log_substep("Creating new multirepo config...")
55
+
56
+ valid_repos = find_valid_repos(sibling_repos)
57
+ entries = create_entries(valid_repos)
58
+
59
+ raise MultiRepoException, "No sibling repositories were added as dependencies; init aborted" unless entries.any?
60
+
61
+ ConfigFile.new(".").save_entries(entries)
62
+ return true
63
+ end
64
+
65
+ def initialize_extras_step
66
+ install_hooks_step
67
+ update_gitattributes_step
68
+ update_gitconfig_step
69
+ end
70
+
71
+ def install_hooks_step
72
+ install_hooks(".")
73
+ Console.log_substep("Installed git hooks")
74
+ end
75
+
76
+ def update_gitattributes_step
77
+ TrackingFiles.new(".").files.each do |f|
78
+ filename = f.filename
79
+ regex_escaped_filename = Regexp.quote(filename)
80
+ Utils.append_if_missing("./.gitattributes", /^#{regex_escaped_filename} .*/, "#{filename} merge=ours")
81
+ end
82
+ Console.log_substep("Updated .gitattributes file")
83
+ end
84
+
85
+ def update_gitconfig_step
86
+ update_gitconfig(".")
87
+ Console.log_substep("Updated .git/config file")
88
+ end
89
+
90
+ def find_valid_repos(repos)
91
+ repos.select do |repo|
92
+ next true if repo.head_born?
93
+ Console.log_warning("Ignoring repo '#{repo.path}' because its HEAD is unborn. You must perform at least one commit.")
94
+ end
95
+ end
96
+
97
+ def create_entries(repos)
98
+ entries = []
99
+ repos.each do |repo|
100
+ origin_url = repo.remote('origin').url
101
+ current_branch_name = repo.current_branch.name
102
+
103
+ if Console.ask_yes_no("Do you want to add '#{repo.path}' as a dependency?\n [origin: #{origin_url || "NONE"}, branch: #{current_branch_name}]")
104
+ unless origin_url
105
+ Console.log_warning("Repo 'origin' remote url is not set; skipping")
106
+ next
107
+ end
108
+ entries.push(ConfigEntry.new(repo))
109
+ Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
110
+ end
111
+ end
112
+ return entries
113
+ end
114
+
115
+ def check_repo_exists
116
+ raise MultiRepoException, "There is no folder at path '#{@repo.path}'" unless Dir.exists?(@repo.path)
117
+ raise MultiRepoException, "'#{@repo.path}' is not a repository" unless @repo.exists?
118
+ end
119
+ end
120
120
  end
@@ -1,40 +1,39 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/utility/utils"
3
-
4
- module MultiRepo
5
- class InspectCommand < Command
6
- self.command = "inspect"
7
- self.summary = "Outputs various information about multirepo-enabled repos. For use in scripting and CI scenarios."
8
-
9
- def self.options
10
- [
11
- ['[--version]', 'Outputs the multirepo version that was used to track this revision.'],
12
- ['[--tracked]', 'Whether the current revision is tracked by multirepo or not.']
13
- ].concat(super)
14
- end
15
-
16
- def initialize(argv)
17
- @version = argv.flag?("version")
18
- @tracked = argv.flag?("tracked")
19
- super
20
- end
21
-
22
- def validate!
23
- super
24
- unless validate_only_one_flag(@version, @tracked)
25
- help! "You can't provide more than one operation modifier (--version, --tracked, etc.)"
26
- end
27
- end
28
-
29
- def run
30
- ensure_in_work_tree
31
- ensure_multirepo_enabled
32
-
33
- if @version
34
- puts MetaFile.new(".").load.version
35
- elsif @tracked
36
- puts Utils.is_multirepo_tracked(".").to_s
37
- end
38
- end
39
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/utility/utils"
3
+
4
+ module MultiRepo
5
+ class InspectCommand < Command
6
+ self.command = "inspect"
7
+ self.summary = "Outputs various information about multirepo-enabled repos. For use in scripting and CI scenarios."
8
+
9
+ def self.options
10
+ [
11
+ ['[--version]', 'Outputs the multirepo version that was used to track this revision.'],
12
+ ['[--tracked]', 'Whether the current revision is tracked by multirepo or not.']
13
+ ].concat(super)
14
+ end
15
+
16
+ def initialize(argv)
17
+ @version = argv.flag?("version")
18
+ @tracked = argv.flag?("tracked")
19
+ super
20
+ end
21
+
22
+ def validate!
23
+ super
24
+ unless validate_only_one_flag(@version, @tracked)
25
+ help! "You can't provide more than one operation modifier (--version, --tracked, etc.)"
26
+ end
27
+ end
28
+
29
+ def run
30
+ ensure_in_work_tree
31
+
32
+ if @version
33
+ puts MetaFile.new(".").load.version
34
+ elsif @tracked
35
+ puts Utils.is_multirepo_tracked(".").to_s
36
+ end
37
+ end
38
+ end
40
39
  end
@@ -1,138 +1,147 @@
1
- require "terminal-table"
2
-
3
- require "multirepo/utility/console"
4
- require "multirepo/utility/utils"
5
- require "multirepo/git/repo"
6
- require "multirepo/logic/performer"
7
- require "multirepo/commands/checkout-command"
8
-
9
- module MultiRepo
10
- class InstallCommand < Command
11
- self.command = "install"
12
- self.summary = "Clones and checks out dependencies as defined in the version-controlled multirepo metadata files and installs git-multirepo's local git hooks."
13
-
14
- def self.options
15
- [
16
- ['[--hooks]', 'Only install local git hooks.'],
17
- ['[--ci]', 'For use in a continuous integration context (such as on a CI build server or agent).']
18
- ].concat(super)
19
- end
20
-
21
- def initialize(argv)
22
- @hooks = argv.flag?("hooks")
23
- @ci = argv.flag?("ci")
24
- super
25
- end
26
-
27
- def validate!
28
- super
29
- unless validate_only_one_flag(@hooks, @ci)
30
- help! "You can't provide more than one operation modifier (--hooks, --ci, etc.)"
31
- end
32
- end
33
-
34
- def run
35
- ensure_in_work_tree unless @ci
36
- ensure_multirepo_tracked
37
-
38
- if @hooks
39
- Console.log_step("Installing hooks in main repo and all dependencies...")
40
- install_hooks_step
41
- else
42
- Console.log_step("Installing dependencies...")
43
- log_ci_info if @ci
44
- full_install
45
- end
46
-
47
- Console.log_step("Done!")
48
- end
49
-
50
- def log_ci_info
51
- Console.log_warning("Performing continuous-integration-aware install")
52
-
53
- meta_file = MetaFile.new(".").load
54
- lock_entries = LockFile.new(".").load_entries
55
- table = Terminal::Table.new do |t|
56
- t.title = "Revision Info"
57
- t.add_row ["git-multirepo version", meta_file.version]
58
- lock_entries.each do |lock_entry|
59
- branch = lock_entry.branch
60
- t.add_row [lock_entry.name, lock_entry.head + (branch ? " (on branch #{branch})" : "")]
61
- end
62
- end
63
- puts table
64
- end
65
-
66
- def full_install
67
- install_dependencies_step
68
- install_hooks_step unless @ci
69
- update_gitconfigs_step unless @ci
70
- end
71
-
72
- def install_dependencies_step
73
- # Read config entries as-is on disk, without prior checkout
74
- config_entries = ConfigFile.new(".").load_entries
75
- Console.log_substep("Installing #{config_entries.count} dependencies...");
76
-
77
- # Clone or fetch all configured dependencies to make sure nothing is missing locally
78
- Performer.dependencies.each { |d| clone_or_fetch(d) }
79
-
80
- # Checkout the appropriate branches as specified in the lock file
81
- checkout_command = CheckoutCommand.new(CLAide::ARGV.new([]))
82
- mode = @ci ? RevisionSelectionMode::AS_LOCK : RevisionSelectionMode::LATEST
83
- checkout_command.dependencies_checkout_step(mode)
84
- end
85
-
86
- def install_hooks_step
87
- perform_in_main_repo_and_dependencies("Installed git hooks") { |repo| install_hooks(repo) }
88
- end
89
-
90
- def update_gitconfigs_step
91
- perform_in_main_repo_and_dependencies("Updated .git/config file") { |repo| update_gitconfig(repo) }
92
- end
93
-
94
- def perform_in_main_repo_and_dependencies(message_prefix, &operation)
95
- operation.call(".")
96
- Console.log_substep("#{message_prefix} in main repo")
97
-
98
- multirepo_enabled_dependencies.each do |config_entry|
99
- operation.call(config_entry.repo.path)
100
- Console.log_substep("#{message_prefix} in multirepo-enabled dependency '#{config_entry.repo.path}'")
101
- end
102
- end
103
-
104
- # Repo operations
105
-
106
- def clone_or_fetch(dependency)
107
- if dependency.config_entry.repo.exists?
108
- check_repo_validity(dependency)
109
-
110
- Console.log_substep("Working copy '#{dependency.config_entry.repo.path}' already exists, fetching...")
111
- fetch_repo(dependency)
112
- else
113
- Console.log_substep("Cloning #{dependency.config_entry.url} into '#{dependency.config_entry.repo.path}'")
114
- clone_repo(dependency)
115
- end
116
- end
117
-
118
- def fetch_repo(dependency)
119
- unless dependency.config_entry.repo.fetch
120
- raise MultiRepoException, "Could not fetch from remote #{dependency.config_entry.repo.remote('origin').url}"
121
- end
122
- end
123
-
124
- def clone_repo(dependency)
125
- unless dependency.config_entry.repo.clone(dependency.config_entry.url, dependency.lock_entry.branch)
126
- raise MultiRepoException, "Could not clone remote #{dependency.config_entry.url} with branch #{dependency.config_entry.branch}"
127
- end
128
- end
129
-
130
- # Validation
131
-
132
- def check_repo_validity(dependency)
133
- unless dependency.config_entry.repo.remote("origin").url == dependency.config_entry.url
134
- raise MultiRepoException, "'#{dependency.config_entry.path}' origin URL (#{dependency.config_entry.repo.remote('origin').url}) does not match entry (#{dependency.config_entry.url})!"
135
- end
136
- end
137
- end
1
+ require "terminal-table"
2
+
3
+ require "multirepo/utility/console"
4
+ require "multirepo/utility/utils"
5
+ require "multirepo/git/repo"
6
+ require "multirepo/logic/performer"
7
+ require "multirepo/commands/checkout-command"
8
+
9
+ module MultiRepo
10
+ class InstallCommand < Command
11
+ self.command = "install"
12
+ self.summary = "Clones and checks out dependencies as defined in the version-controlled multirepo metadata files and installs git-multirepo's local git hooks."
13
+
14
+ def self.options
15
+ [
16
+ ['[--hooks]', 'Only install local git hooks.'],
17
+ ['[--ci]', 'Perform a continuous-integration-aware install (such as on a CI build server or agent).']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @hooks = argv.flag?("hooks")
23
+ @ci = argv.flag?("ci")
24
+ super
25
+ end
26
+
27
+ def validate!
28
+ super
29
+ unless validate_only_one_flag(@hooks, @ci)
30
+ help! "You can't provide more than one operation modifier (--hooks, --ci, etc.)"
31
+ end
32
+ end
33
+
34
+ def run
35
+ ensure_in_work_tree unless @ci
36
+ ensure_multirepo_tracked
37
+
38
+ if @hooks
39
+ Console.log_step("Installing hooks in main repo and all dependencies...")
40
+ install_hooks_step
41
+ else
42
+ Console.log_step("Installing dependencies...")
43
+ log_ci_info if @ci
44
+ full_install
45
+ end
46
+
47
+ Console.log_step("Done!")
48
+ end
49
+
50
+ def log_ci_info
51
+ Console.log_warning("Performing continuous-integration-aware install")
52
+
53
+ main_repo = Repo.new(".")
54
+ main_repo_branch = main_repo.current_branch
55
+ meta_file = MetaFile.new(".").load
56
+
57
+ table = Terminal::Table.new do |t|
58
+ t.title = "Revision Info"
59
+ t.add_row ["git-multirepo version", meta_file.version]
60
+ t.add_separator
61
+ t.add_row ["Main Repo", commit_info(main_repo.head.commit_id, (main_repo_branch.name rescue nil))]
62
+ t.add_separator
63
+ LockFile.new(".").load_entries.each do |lock_entry|
64
+ branch_name = lock_entry.branch
65
+ t.add_row [lock_entry.name, commit_info(lock_entry.head, branch_name)]
66
+ end
67
+ end
68
+ puts table
69
+ end
70
+
71
+ def commit_info(commit_id, branch_name)
72
+ commit_id + (branch_name ? " (on branch #{branch_name})" : "")
73
+ end
74
+
75
+ def full_install
76
+ install_dependencies_step
77
+ install_hooks_step unless @ci
78
+ update_gitconfigs_step unless @ci
79
+ end
80
+
81
+ def install_dependencies_step
82
+ # Read config entries as-is on disk, without prior checkout
83
+ config_entries = ConfigFile.new(".").load_entries
84
+ Console.log_substep("Installing #{config_entries.count} dependencies...");
85
+
86
+ # Clone or fetch all configured dependencies to make sure nothing is missing locally
87
+ Performer.dependencies.each { |d| clone_or_fetch(d) }
88
+
89
+ # Checkout the appropriate branches as specified in the lock file
90
+ checkout_command = CheckoutCommand.new(CLAide::ARGV.new([]))
91
+ mode = @ci ? RevisionSelectionMode::AS_LOCK : RevisionSelectionMode::LATEST
92
+ checkout_command.dependencies_checkout_step(mode)
93
+ end
94
+
95
+ def install_hooks_step
96
+ perform_in_main_repo_and_dependencies("Installed git hooks") { |repo| install_hooks(repo) }
97
+ end
98
+
99
+ def update_gitconfigs_step
100
+ perform_in_main_repo_and_dependencies("Updated .git/config file") { |repo| update_gitconfig(repo) }
101
+ end
102
+
103
+ def perform_in_main_repo_and_dependencies(message_prefix, &operation)
104
+ operation.call(".")
105
+ Console.log_substep("#{message_prefix} in main repo")
106
+
107
+ multirepo_enabled_dependencies.each do |config_entry|
108
+ operation.call(config_entry.repo.path)
109
+ Console.log_substep("#{message_prefix} in multirepo-enabled dependency '#{config_entry.repo.path}'")
110
+ end
111
+ end
112
+
113
+ # Repo operations
114
+
115
+ def clone_or_fetch(dependency)
116
+ if dependency.config_entry.repo.exists?
117
+ check_repo_validity(dependency)
118
+
119
+ Console.log_substep("Working copy '#{dependency.config_entry.repo.path}' already exists, fetching...")
120
+ fetch_repo(dependency)
121
+ else
122
+ Console.log_substep("Cloning #{dependency.config_entry.url} into '#{dependency.config_entry.repo.path}'")
123
+ clone_repo(dependency)
124
+ end
125
+ end
126
+
127
+ def fetch_repo(dependency)
128
+ unless dependency.config_entry.repo.fetch
129
+ raise MultiRepoException, "Could not fetch from remote #{dependency.config_entry.repo.remote('origin').url}"
130
+ end
131
+ end
132
+
133
+ def clone_repo(dependency)
134
+ unless dependency.config_entry.repo.clone(dependency.config_entry.url, dependency.lock_entry.branch)
135
+ raise MultiRepoException, "Could not clone remote #{dependency.config_entry.url} with branch #{dependency.config_entry.branch}"
136
+ end
137
+ end
138
+
139
+ # Validation
140
+
141
+ def check_repo_validity(dependency)
142
+ unless dependency.config_entry.repo.remote("origin").url == dependency.config_entry.url
143
+ raise MultiRepoException, "'#{dependency.config_entry.path}' origin URL (#{dependency.config_entry.repo.remote('origin').url}) does not match entry (#{dependency.config_entry.url})!"
144
+ end
145
+ end
146
+ end
138
147
  end