git-multirepo 1.0.0.beta65 → 1.0.0.beta66

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +4 -4
  3. data/.gitbugtraq +3 -3
  4. data/.gitignore +38 -38
  5. data/.rspec +2 -2
  6. data/.rubocop.yml +79 -79
  7. data/CHANGELOG.md +95 -91
  8. data/Gemfile +4 -4
  9. data/Gemfile.lock +47 -47
  10. data/LICENSE +22 -22
  11. data/README.md +178 -178
  12. data/Rakefile +1 -1
  13. data/bin/multi +11 -11
  14. data/docs/bug-repros/91565510-repro.sh +20 -20
  15. data/git-multirepo.gemspec +31 -31
  16. data/lib/git-multirepo.rb +3 -3
  17. data/lib/multirepo/commands/add-command.rb +51 -51
  18. data/lib/multirepo/commands/branch-command.rb +88 -88
  19. data/lib/multirepo/commands/checkout-command.rb +127 -127
  20. data/lib/multirepo/commands/clone-command.rb +68 -68
  21. data/lib/multirepo/commands/command.rb +87 -87
  22. data/lib/multirepo/commands/commands.rb +14 -14
  23. data/lib/multirepo/commands/do-command.rb +101 -101
  24. data/lib/multirepo/commands/init-command.rb +121 -121
  25. data/lib/multirepo/commands/inspect-command.rb +48 -48
  26. data/lib/multirepo/commands/install-command.rb +170 -170
  27. data/lib/multirepo/commands/merge-command.rb +251 -249
  28. data/lib/multirepo/commands/open-command.rb +55 -55
  29. data/lib/multirepo/commands/remove-command.rb +48 -48
  30. data/lib/multirepo/commands/uninit-command.rb +18 -18
  31. data/lib/multirepo/commands/update-command.rb +112 -112
  32. data/lib/multirepo/config.rb +19 -19
  33. data/lib/multirepo/files/config-entry.rb +39 -39
  34. data/lib/multirepo/files/config-file.rb +52 -52
  35. data/lib/multirepo/files/lock-entry.rb +29 -29
  36. data/lib/multirepo/files/lock-file.rb +62 -62
  37. data/lib/multirepo/files/meta-file.rb +51 -51
  38. data/lib/multirepo/files/tracking-file.rb +9 -9
  39. data/lib/multirepo/files/tracking-files.rb +64 -64
  40. data/lib/multirepo/git/branch.rb +32 -32
  41. data/lib/multirepo/git/change.rb +11 -11
  42. data/lib/multirepo/git/commit.rb +7 -7
  43. data/lib/multirepo/git/git-runner.rb +56 -56
  44. data/lib/multirepo/git/git.rb +10 -10
  45. data/lib/multirepo/git/ref.rb +38 -38
  46. data/lib/multirepo/git/remote.rb +17 -17
  47. data/lib/multirepo/git/repo.rb +129 -129
  48. data/lib/multirepo/hooks/post-commit-hook.rb +23 -23
  49. data/lib/multirepo/hooks/pre-commit-hook.rb +35 -35
  50. data/lib/multirepo/info.rb +5 -5
  51. data/lib/multirepo/logic/dependency.rb +6 -6
  52. data/lib/multirepo/logic/merge-descriptor.rb +95 -95
  53. data/lib/multirepo/logic/node.rb +72 -72
  54. data/lib/multirepo/logic/performer.rb +55 -55
  55. data/lib/multirepo/logic/repo-selection.rb +25 -25
  56. data/lib/multirepo/logic/revision-selection.rb +15 -15
  57. data/lib/multirepo/logic/revision-selector.rb +23 -23
  58. data/lib/multirepo/logic/version-comparer.rb +10 -10
  59. data/lib/multirepo/multirepo-exception.rb +6 -6
  60. data/lib/multirepo/output/extra-output.rb +12 -12
  61. data/lib/multirepo/output/teamcity-extra-output.rb +11 -11
  62. data/lib/multirepo/utility/console.rb +52 -52
  63. data/lib/multirepo/utility/popen-runner.rb +27 -27
  64. data/lib/multirepo/utility/system-runner.rb +14 -14
  65. data/lib/multirepo/utility/utils.rb +99 -99
  66. data/lib/multirepo/utility/verbosity.rb +6 -6
  67. data/resources/.gitconfig +2 -2
  68. data/resources/post-commit +0 -0
  69. data/resources/pre-commit +0 -0
  70. data/spec/integration/init_spec.rb +19 -19
  71. data/spec/spec_helper.rb +89 -89
  72. metadata +3 -3
@@ -1,249 +1,251 @@
1
- require "terminal-table"
2
-
3
- require "multirepo/utility/console"
4
- require "multirepo/utility/utils"
5
- require "multirepo/logic/node"
6
- require "multirepo/logic/revision-selector"
7
- require "multirepo/logic/repo-selection"
8
- require "multirepo/logic/performer"
9
- require "multirepo/logic/merge-descriptor"
10
- require "multirepo/files/tracking-files"
11
- require "multirepo/commands/update-command"
12
-
13
- module MultiRepo
14
- class MergeValidationResult
15
- ABORT = 0
16
- PROCEED = 1
17
- MERGE_UPSTREAM = 2
18
-
19
- attr_accessor :outcome
20
- attr_accessor :message
21
- end
22
-
23
- class MergeCommand < Command
24
- self.command = "merge"
25
- self.summary = "Performs a git merge on all dependencies and the main repo, in the proper order."
26
-
27
- def self.options
28
- [
29
- ['<refname>', 'The main repo tag, branch or commit id to merge.'],
30
- ['[--latest]', 'Merge the HEAD of each stored dependency branch instead of the commits recorded in the lock file.'],
31
- ['[--exact]', 'Merge the exact specified ref for each repo, regardless of what\'s stored in the lock file.']
32
- ].concat(super)
33
- end
34
-
35
- def initialize(argv)
36
- @ref_name = argv.shift_argument
37
- @checkout_latest = argv.flag?("latest")
38
- @checkout_exact = argv.flag?("exact")
39
- super
40
- end
41
-
42
- def validate!
43
- super
44
- help! "You must specify a ref to merge" unless @ref_name
45
- unless Utils.only_one_true?(@checkout_latest, @checkout_exact)
46
- help! "You can't provide more than one operation modifier (--latest, --exact, etc.)"
47
- end
48
- end
49
-
50
- def run
51
- ensure_in_work_tree
52
- ensure_multirepo_enabled
53
-
54
- # Find out the checkout mode based on command-line options
55
- mode = RevisionSelector.mode_for_args(@checkout_latest, @checkout_exact)
56
-
57
- strategy_name = RevisionSelection.name_for_mode(mode)
58
- Console.log_step("Merging #{@ref_name} with '#{strategy_name}' strategy...")
59
-
60
- main_repo = Repo.new(".")
61
-
62
- # Keep the initial revision because we're going to need to come back to it later
63
- initial_revision = main_repo.current_revision
64
-
65
- begin
66
- merge_core(main_repo, initial_revision, mode)
67
- rescue MultiRepoException => e
68
- # Revert to the initial revision only if necessary
69
- unless main_repo.current_revision == initial_revision
70
- Console.log_warning("Restoring working copy to #{initial_revision}")
71
- main_repo.checkout(initial_revision)
72
- end
73
- raise e
74
- end
75
-
76
- Console.log_step("Done!")
77
- end
78
-
79
- def merge_core(main_repo, initial_revision, mode)
80
- config_file = ConfigFile.new(".")
81
-
82
- # Ensure the main repo is clean
83
- fail MultiRepoException, "Main repo is not clean; merge aborted" unless main_repo.clean?
84
-
85
- # Ensure dependencies are clean
86
- unless Utils.dependencies_clean?(config_file.load_entries)
87
- fail MultiRepoException, "Dependencies are not clean; merge aborted"
88
- end
89
-
90
- ref_name = @ref_name
91
- descriptors = nil
92
- loop do
93
- # Gather information about the merges that would occur
94
- descriptors = build_merge(main_repo, initial_revision, ref_name, mode)
95
-
96
- # Preview merge operations in the console
97
- preview_merge(descriptors, mode, ref_name)
98
-
99
- # Validate merge operations
100
- result = ensure_merge_valid(descriptors)
101
-
102
- case result.outcome
103
- when MergeValidationResult::ABORT
104
- fail MultiRepoException, result.message
105
- when MergeValidationResult::PROCEED
106
- fail MultiRepoException, "Merge aborted" unless Console.ask("Proceed?")
107
- Console.log_warning(result.message) if result.message
108
- break
109
- when MergeValidationResult::MERGE_UPSTREAM
110
- Console.log_warning(result.message)
111
- fail MultiRepoException, "Merge aborted" unless Console.ask("Merge upstream instead of local branches?")
112
- # TODO: Modify operations!
113
- fail MultiRepoException, "Fallback behavior not implemented. Please merge manually."
114
- next
115
- end
116
-
117
- fail MultiRepoException, "Merge aborted" unless Console.ask("Proceed?")
118
- end
119
-
120
- Console.log_step("Performing merge...")
121
-
122
- all_succeeded = perform_merges(descriptors)
123
- ask_tracking_files_update(all_succeeded)
124
- end
125
-
126
- def build_merge(main_repo, initial_revision, ref_name, mode)
127
- # List dependencies prior to checkout so that we can compare them later
128
- our_dependencies = Performer.depth_ordered_dependencies
129
-
130
- # Checkout the specified main repo ref to find out which dependency refs to merge
131
- commit_id = Ref.new(main_repo, ref_name).commit_id # Checkout in floating HEAD
132
- Performer.perform_main_repo_checkout(main_repo, commit_id, false, "Checked out main repo '#{ref_name}' to inspect to-merge dependencies")
133
-
134
- # List dependencies for the ref we're trying to merge
135
- their_dependencies = Performer.depth_ordered_dependencies
136
-
137
- # Checkout the initial revision ASAP
138
- Performer.perform_main_repo_checkout(main_repo, initial_revision, false, "Checked out initial main repo revision '#{initial_revision}'")
139
-
140
- # Auto-merge would be too complex to implement (due to lots of edge cases)
141
- # if the specified ref does not have the same dependencies. Better perform a manual merge.
142
- ensure_dependencies_match(our_dependencies, their_dependencies)
143
-
144
- # Create a merge descriptor for each would-be merge as well as the main repo.
145
- # This step MUST be performed in OUR revision for the merge descriptors to be correct!
146
- descriptors = build_dependency_merge_descriptors(our_dependencies, their_dependencies, ref_name, mode)
147
- descriptors.push(MergeDescriptor.new("Main Repo", main_repo, initial_revision, ref_name))
148
-
149
- return descriptors
150
- end
151
-
152
- def build_dependency_merge_descriptors(our_dependencies, their_dependencies, ref_name, mode)
153
- descriptors = []
154
- our_dependencies.zip(their_dependencies).each do |our_dependency, their_dependency|
155
- our_revision = our_dependency.config_entry.repo.current_revision
156
-
157
- their_revision = RevisionSelector.revision_for_mode(mode, ref_name, their_dependency.lock_entry)
158
- their_name = their_dependency.config_entry.name
159
- their_repo = their_dependency.config_entry.repo
160
-
161
- descriptor = MergeDescriptor.new(their_name, their_repo, our_revision, their_revision)
162
-
163
- descriptors.push(descriptor)
164
- end
165
- return descriptors
166
- end
167
-
168
- def ensure_dependencies_match(our_dependencies, their_dependencies)
169
- our_dependencies.zip(their_dependencies).each do |our_dependency, their_dependency|
170
- if their_dependency.nil? || their_dependency.config_entry.id != our_dependency.config_entry.id
171
- fail MultiRepoException, "Dependencies differ, please merge manually"
172
- end
173
- end
174
-
175
- if their_dependencies.count > our_dependencies.count
176
- fail MultiRepoException, "There are more dependencies in the specified ref, please merge manually"
177
- end
178
- end
179
-
180
- def preview_merge(descriptors, mode, ref_name)
181
- Console.log_info("Merging would #{message_for_mode(mode, ref_name)}:")
182
-
183
- table = Terminal::Table.new do |t|
184
- descriptors.reverse.each_with_index do |descriptor, index|
185
- t.add_row [descriptor.name.bold, descriptor.merge_description, descriptor.upstream_description]
186
- t.add_separator unless index == descriptors.count - 1
187
- end
188
- end
189
- puts table
190
- end
191
-
192
- def ensure_merge_valid(descriptors)
193
- outcome = MergeValidationResult.new
194
- outcome.outcome = MergeValidationResult::PROCEED
195
-
196
- if descriptors.any? { |d| d.state == TheirState::LOCAL_NO_UPSTREAM }
197
- outcome.message = "Some branches are not remote-tracking! Please review the merge operations above."
198
- elsif descriptors.any? { |d| d.state == TheirState::LOCAL_UPSTREAM_DIVERGED }
199
- outcome.outcome = MergeValidationResult::ABORT
200
- outcome.message = "Some upstream branches have diverged. This warrants a manual merge!"
201
- elsif descriptors.any? { |d| d.state == TheirState::LOCAL_OUTDATED }
202
- outcome.outcome = MergeValidationResult::MERGE_UPSTREAM
203
- outcome.message = "Some local branches are outdated"
204
- end
205
-
206
- return outcome
207
- end
208
-
209
- def perform_merges(descriptors)
210
- success = true
211
- descriptors.each do |descriptor|
212
- Console.log_substep("#{descriptor.name} : Merging #{descriptor.their_revision} into #{descriptor.our_revision}...")
213
- GitRunner.run_as_system(descriptor.repo.path, "merge #{descriptor.their_revision}")
214
- success &= GitRunner.last_command_succeeded
215
- end
216
-
217
- if success
218
- Console.log_info("All merges performed successfully!")
219
- else
220
- Console.log_warning("Some merge operations failed. Please review the above.")
221
- end
222
-
223
- return success
224
- end
225
-
226
- def ask_tracking_files_update(all_merges_succeeded)
227
- unless all_merges_succeeded
228
- Console.log_warning("Perform a 'multi update' after resolving merge conflicts to ensure lock file contents are valid")
229
- return
230
- end
231
-
232
- return unless Console.ask("Update main repo tracking files? (important for continuous integration)")
233
-
234
- update_command = UpdateCommand.new(CLAide::ARGV.new(["--commit", "--diff"]))
235
- update_command.update_tracking_files_step(RepoSelection::MAIN)
236
- end
237
-
238
- def message_for_mode(mode, ref_name)
239
- case mode
240
- when RevisionSelection::AS_LOCK
241
- "merge specific commits as stored in the lock file for main repo revision #{ref_name}"
242
- when RevisionSelection::LATEST
243
- "merge each branch as stored in the lock file of main repo revision #{ref_name}"
244
- when RevisionSelection::EXACT
245
- "merge #{ref_name} for each repository, ignoring the contents of the lock file"
246
- end
247
- end
248
- end
249
- end
1
+ require "terminal-table"
2
+
3
+ require "multirepo/utility/console"
4
+ require "multirepo/utility/utils"
5
+ require "multirepo/logic/node"
6
+ require "multirepo/logic/revision-selector"
7
+ require "multirepo/logic/repo-selection"
8
+ require "multirepo/logic/performer"
9
+ require "multirepo/logic/merge-descriptor"
10
+ require "multirepo/files/tracking-files"
11
+ require "multirepo/commands/update-command"
12
+
13
+ module MultiRepo
14
+ class MergeValidationResult
15
+ ABORT = 0
16
+ PROCEED = 1
17
+ MERGE_UPSTREAM = 2
18
+
19
+ attr_accessor :outcome
20
+ attr_accessor :message
21
+ end
22
+
23
+ class MergeCommand < Command
24
+ self.command = "merge"
25
+ self.summary = "Performs a git merge on all dependencies and the main repo, in the proper order."
26
+
27
+ def self.options
28
+ [
29
+ ['<refname>', 'The main repo tag, branch or commit id to merge.'],
30
+ ['[--latest]', 'Merge the HEAD of each stored dependency branch instead of the commits recorded in the lock file.'],
31
+ ['[--exact]', 'Merge the exact specified ref for each repo, regardless of what\'s stored in the lock file.'],
32
+ ['[--no-ff]', 'Never perform a fast-forward.']
33
+ ].concat(super)
34
+ end
35
+
36
+ def initialize(argv)
37
+ @ref_name = argv.shift_argument
38
+ @checkout_latest = argv.flag?("latest")
39
+ @checkout_exact = argv.flag?("exact")
40
+ @fast_forward = argv.flag?("ff")
41
+ super
42
+ end
43
+
44
+ def validate!
45
+ super
46
+ help! "You must specify a ref to merge" unless @ref_name
47
+ unless Utils.only_one_true?(@checkout_latest, @checkout_exact)
48
+ help! "You can't provide more than one operation modifier (--latest, --exact, etc.)"
49
+ end
50
+ end
51
+
52
+ def run
53
+ ensure_in_work_tree
54
+ ensure_multirepo_enabled
55
+
56
+ # Find out the checkout mode based on command-line options
57
+ mode = RevisionSelector.mode_for_args(@checkout_latest, @checkout_exact)
58
+
59
+ strategy_name = RevisionSelection.name_for_mode(mode)
60
+ Console.log_step("Merging #{@ref_name} with '#{strategy_name}' strategy...")
61
+
62
+ main_repo = Repo.new(".")
63
+
64
+ # Keep the initial revision because we're going to need to come back to it later
65
+ initial_revision = main_repo.current_revision
66
+
67
+ begin
68
+ merge_core(main_repo, initial_revision, mode)
69
+ rescue MultiRepoException => e
70
+ # Revert to the initial revision only if necessary
71
+ unless main_repo.current_revision == initial_revision
72
+ Console.log_warning("Restoring working copy to #{initial_revision}")
73
+ main_repo.checkout(initial_revision)
74
+ end
75
+ raise e
76
+ end
77
+
78
+ Console.log_step("Done!")
79
+ end
80
+
81
+ def merge_core(main_repo, initial_revision, mode)
82
+ config_file = ConfigFile.new(".")
83
+
84
+ # Ensure the main repo is clean
85
+ fail MultiRepoException, "Main repo is not clean; merge aborted" unless main_repo.clean?
86
+
87
+ # Ensure dependencies are clean
88
+ unless Utils.dependencies_clean?(config_file.load_entries)
89
+ fail MultiRepoException, "Dependencies are not clean; merge aborted"
90
+ end
91
+
92
+ ref_name = @ref_name
93
+ descriptors = nil
94
+ loop do
95
+ # Gather information about the merges that would occur
96
+ descriptors = build_merge(main_repo, initial_revision, ref_name, mode)
97
+
98
+ # Preview merge operations in the console
99
+ preview_merge(descriptors, mode, ref_name)
100
+
101
+ # Validate merge operations
102
+ result = ensure_merge_valid(descriptors)
103
+
104
+ case result.outcome
105
+ when MergeValidationResult::ABORT
106
+ fail MultiRepoException, result.message
107
+ when MergeValidationResult::PROCEED
108
+ fail MultiRepoException, "Merge aborted" unless Console.ask("Proceed?")
109
+ Console.log_warning(result.message) if result.message
110
+ break
111
+ when MergeValidationResult::MERGE_UPSTREAM
112
+ Console.log_warning(result.message)
113
+ fail MultiRepoException, "Merge aborted" unless Console.ask("Merge upstream instead of local branches?")
114
+ # TODO: Modify operations!
115
+ fail MultiRepoException, "Fallback behavior not implemented. Please merge manually."
116
+ next
117
+ end
118
+
119
+ fail MultiRepoException, "Merge aborted" unless Console.ask("Proceed?")
120
+ end
121
+
122
+ Console.log_step("Performing merge...")
123
+
124
+ all_succeeded = perform_merges(descriptors)
125
+ ask_tracking_files_update(all_succeeded)
126
+ end
127
+
128
+ def build_merge(main_repo, initial_revision, ref_name, mode)
129
+ # List dependencies prior to checkout so that we can compare them later
130
+ our_dependencies = Performer.depth_ordered_dependencies
131
+
132
+ # Checkout the specified main repo ref to find out which dependency refs to merge
133
+ commit_id = Ref.new(main_repo, ref_name).commit_id # Checkout in floating HEAD
134
+ Performer.perform_main_repo_checkout(main_repo, commit_id, false, "Checked out main repo '#{ref_name}' to inspect to-merge dependencies")
135
+
136
+ # List dependencies for the ref we're trying to merge
137
+ their_dependencies = Performer.depth_ordered_dependencies
138
+
139
+ # Checkout the initial revision ASAP
140
+ Performer.perform_main_repo_checkout(main_repo, initial_revision, false, "Checked out initial main repo revision '#{initial_revision}'")
141
+
142
+ # Auto-merge would be too complex to implement (due to lots of edge cases)
143
+ # if the specified ref does not have the same dependencies. Better perform a manual merge.
144
+ ensure_dependencies_match(our_dependencies, their_dependencies)
145
+
146
+ # Create a merge descriptor for each would-be merge as well as the main repo.
147
+ # This step MUST be performed in OUR revision for the merge descriptors to be correct!
148
+ descriptors = build_dependency_merge_descriptors(our_dependencies, their_dependencies, ref_name, mode)
149
+ descriptors.push(MergeDescriptor.new("Main Repo", main_repo, initial_revision, ref_name))
150
+
151
+ return descriptors
152
+ end
153
+
154
+ def build_dependency_merge_descriptors(our_dependencies, their_dependencies, ref_name, mode)
155
+ descriptors = []
156
+ our_dependencies.zip(their_dependencies).each do |our_dependency, their_dependency|
157
+ our_revision = our_dependency.config_entry.repo.current_revision
158
+
159
+ their_revision = RevisionSelector.revision_for_mode(mode, ref_name, their_dependency.lock_entry)
160
+ their_name = their_dependency.config_entry.name
161
+ their_repo = their_dependency.config_entry.repo
162
+
163
+ descriptor = MergeDescriptor.new(their_name, their_repo, our_revision, their_revision)
164
+
165
+ descriptors.push(descriptor)
166
+ end
167
+ return descriptors
168
+ end
169
+
170
+ def ensure_dependencies_match(our_dependencies, their_dependencies)
171
+ our_dependencies.zip(their_dependencies).each do |our_dependency, their_dependency|
172
+ if their_dependency.nil? || their_dependency.config_entry.id != our_dependency.config_entry.id
173
+ fail MultiRepoException, "Dependencies differ, please merge manually"
174
+ end
175
+ end
176
+
177
+ if their_dependencies.count > our_dependencies.count
178
+ fail MultiRepoException, "There are more dependencies in the specified ref, please merge manually"
179
+ end
180
+ end
181
+
182
+ def preview_merge(descriptors, mode, ref_name)
183
+ Console.log_info("Merging would #{message_for_mode(mode, ref_name)}:")
184
+
185
+ table = Terminal::Table.new do |t|
186
+ descriptors.reverse.each_with_index do |descriptor, index|
187
+ t.add_row [descriptor.name.bold, descriptor.merge_description, descriptor.upstream_description]
188
+ t.add_separator unless index == descriptors.count - 1
189
+ end
190
+ end
191
+ puts table
192
+ end
193
+
194
+ def ensure_merge_valid(descriptors)
195
+ outcome = MergeValidationResult.new
196
+ outcome.outcome = MergeValidationResult::PROCEED
197
+
198
+ if descriptors.any? { |d| d.state == TheirState::LOCAL_NO_UPSTREAM }
199
+ outcome.message = "Some branches are not remote-tracking! Please review the merge operations above."
200
+ elsif descriptors.any? { |d| d.state == TheirState::LOCAL_UPSTREAM_DIVERGED }
201
+ outcome.outcome = MergeValidationResult::ABORT
202
+ outcome.message = "Some upstream branches have diverged. This warrants a manual merge!"
203
+ elsif descriptors.any? { |d| d.state == TheirState::LOCAL_OUTDATED }
204
+ outcome.outcome = MergeValidationResult::MERGE_UPSTREAM
205
+ outcome.message = "Some local branches are outdated"
206
+ end
207
+
208
+ return outcome
209
+ end
210
+
211
+ def perform_merges(descriptors)
212
+ success = true
213
+ descriptors.each do |descriptor|
214
+ Console.log_substep("#{descriptor.name} : Merging #{descriptor.their_revision} into #{descriptor.our_revision}...")
215
+ GitRunner.run_as_system(descriptor.repo.path, "merge #{descriptor.their_revision}#{@fast_forward ? '' : ' --no-ff'}")
216
+ success &= GitRunner.last_command_succeeded
217
+ end
218
+
219
+ if success
220
+ Console.log_info("All merges performed successfully!")
221
+ else
222
+ Console.log_warning("Some merge operations failed. Please review the above.")
223
+ end
224
+
225
+ return success
226
+ end
227
+
228
+ def ask_tracking_files_update(all_merges_succeeded)
229
+ unless all_merges_succeeded
230
+ Console.log_warning("Perform a 'multi update' after resolving merge conflicts to ensure lock file contents are valid")
231
+ return
232
+ end
233
+
234
+ return unless Console.ask("Update main repo tracking files? (important for continuous integration)")
235
+
236
+ update_command = UpdateCommand.new(CLAide::ARGV.new(["--commit", "--diff"]))
237
+ update_command.update_tracking_files_step(RepoSelection::MAIN)
238
+ end
239
+
240
+ def message_for_mode(mode, ref_name)
241
+ case mode
242
+ when RevisionSelection::AS_LOCK
243
+ "merge specific commits as stored in the lock file for main repo revision #{ref_name}"
244
+ when RevisionSelection::LATEST
245
+ "merge each branch as stored in the lock file of main repo revision #{ref_name}"
246
+ when RevisionSelection::EXACT
247
+ "merge #{ref_name} for each repository, ignoring the contents of the lock file"
248
+ end
249
+ end
250
+ end
251
+ end
@@ -1,55 +1,55 @@
1
- require "os"
2
-
3
- require "multirepo/utility/console"
4
- require "multirepo/utility/utils"
5
- require "multirepo/logic/repo-selection"
6
-
7
- module MultiRepo
8
- class OpenCommand < Command
9
- self.command = "open"
10
- self.summary = "Opens repositories in the OS's file explorer."
11
-
12
- def self.options
13
- [
14
- ['[--all]', 'Open the main repository and all dependencies.'],
15
- ['[--main]', 'Open the main repository.'],
16
- ['[--deps]', 'Open dependencies.']
17
- ].concat(super)
18
- end
19
-
20
- def initialize(argv)
21
- @repo_selection = RepoSelection.new(argv)
22
- super
23
- end
24
-
25
- def validate!
26
- super
27
- help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
28
- end
29
-
30
- def run
31
- ensure_in_work_tree
32
- ensure_multirepo_enabled
33
-
34
- case @repo_selection.value
35
- when RepoSelection::MAIN
36
- open_main
37
- when RepoSelection::DEPS
38
- open_dependencies
39
- when RepoSelection::ALL
40
- open_dependencies
41
- open_main
42
- end
43
- end
44
-
45
- def open_main
46
- Utils.reveal_in_default_file_browser(".")
47
- end
48
-
49
- def open_dependencies
50
- ConfigFile.new(".").load_entries.each do |entry|
51
- Utils.reveal_in_default_file_browser(entry.repo.path)
52
- end
53
- end
54
- end
55
- end
1
+ require "os"
2
+
3
+ require "multirepo/utility/console"
4
+ require "multirepo/utility/utils"
5
+ require "multirepo/logic/repo-selection"
6
+
7
+ module MultiRepo
8
+ class OpenCommand < Command
9
+ self.command = "open"
10
+ self.summary = "Opens repositories in the OS's file explorer."
11
+
12
+ def self.options
13
+ [
14
+ ['[--all]', 'Open the main repository and all dependencies.'],
15
+ ['[--main]', 'Open the main repository.'],
16
+ ['[--deps]', 'Open dependencies.']
17
+ ].concat(super)
18
+ end
19
+
20
+ def initialize(argv)
21
+ @repo_selection = RepoSelection.new(argv)
22
+ super
23
+ end
24
+
25
+ def validate!
26
+ super
27
+ help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
28
+ end
29
+
30
+ def run
31
+ ensure_in_work_tree
32
+ ensure_multirepo_enabled
33
+
34
+ case @repo_selection.value
35
+ when RepoSelection::MAIN
36
+ open_main
37
+ when RepoSelection::DEPS
38
+ open_dependencies
39
+ when RepoSelection::ALL
40
+ open_dependencies
41
+ open_main
42
+ end
43
+ end
44
+
45
+ def open_main
46
+ Utils.reveal_in_default_file_browser(".")
47
+ end
48
+
49
+ def open_dependencies
50
+ ConfigFile.new(".").load_entries.each do |entry|
51
+ Utils.reveal_in_default_file_browser(entry.repo.path)
52
+ end
53
+ end
54
+ end
55
+ end