git-multirepo 1.0.0.beta50 → 1.0.0.beta51

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96d1c4b54b0bc863b77d19b003b57b427c43a228
4
- data.tar.gz: 1c7ccd22b0b03c32dccae18f0fc21ecd523e92d4
3
+ metadata.gz: f69d3b2b70a1a87eaf12962cb4d324f62368e5e5
4
+ data.tar.gz: 8ff1400b4b192b6ebd80077005f01983baf2691c
5
5
  SHA512:
6
- metadata.gz: 22d584973f5eadf073e03a3767a72700fc8a1ec9390ba4578ff3cd9a2898fe4624245c703ae90aa0bcd75b919ae2de13df626d40d36230c61df893885bd57394
7
- data.tar.gz: 6f5aab921c711670f41a317783624e024c067c657aeba5393671b0119777401d54fb484cf29312e71612cbe0d3510ffdf734edb6c14ad7077b310a61faae17b7
6
+ metadata.gz: 8003b60e23ec40811e2946958285c637aef6ccd537f884912f165a4c142fb49ab147916d653f27138aa18e714bfb9bb63c6a50a674c5cb404af5ae9db35498c5
7
+ data.tar.gz: 493424da5709a8404eb17541accbb49c1d5ed1bce257407e0a1d2ee3c93c551353c9af2b150c502ee47e63ad89f680b1d40ddd2f7c5bf228344bd2dba9b1bb6b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  To install betas run `[sudo] gem install git-multirepo --pre`
4
4
 
5
+ ## 1.0.0.beta51
6
+
7
+ - **Enhancement:** `multi merge` now shows a lock file diff if the user chooses to perform an update after the merge operation
8
+ - **Enhancement:** `multi merge` now uses the same update logic as `multi update` for more robustness and uniformity
9
+ - **Enhancement:** `multi update` has a new `--no-diff` option to skip lock file diffing and shows diff by default
10
+ - **Bug Fix:** `multi update` did not show the lock file diff when the `--commit` flag was specified
11
+ - **Internals:** `multi update`, `multi do` and `multi open` now use common repo-selection logic (--deps, --main, etc.)
12
+
13
+ ## 1.0.0.beta50
14
+
15
+ - **Enhancement:** `multi merge` now asks to update the main repo lock file after a merge (useful for CI scenarios)
16
+ - **Enhancement:** `multi update` now asks to show a lock file diff if the main repo's lock file was modified
17
+ - **Enhancement:** Checking out the main repo in floating HEAD to prevent unnecessary local branch creation in `multi merge`
18
+
5
19
  ## 1.0.0.beta49
6
20
 
7
21
  - **Enhancement:** Added --deps, --main and --all flags to `multi update` and update all by default
@@ -1,4 +1,5 @@
1
1
  require "multirepo/utility/console"
2
+ require "multirepo/utility/utils"
2
3
  require "multirepo/logic/revision-selector"
3
4
  require "multirepo/logic/performer"
4
5
 
@@ -25,7 +26,7 @@ module MultiRepo
25
26
  def validate!
26
27
  super
27
28
  help! "You must specify a branch or commit id to checkout" unless @ref_name
28
- unless validate_only_one_flag(@checkout_latest, @checkout_exact)
29
+ unless Utils.only_one_true?(@checkout_latest, @checkout_exact)
29
30
  help! "You can't provide more than one operation modifier (--latest, --exact, etc.)"
30
31
  end
31
32
  end
@@ -36,7 +37,7 @@ module MultiRepo
36
37
  # Find out the checkout mode based on command-line options
37
38
  mode = RevisionSelector.mode_for_args(@checkout_latest, @checkout_exact)
38
39
 
39
- strategy_name = RevisionSelectionMode.name_for_mode(mode)
40
+ strategy_name = RevisionSelection.name_for_mode(mode)
40
41
  Console.log_step("Checking out #{@ref_name} and its dependencies using the '#{strategy_name}' strategy...")
41
42
 
42
43
  main_repo = Repo.new(".")
@@ -87,11 +88,11 @@ module MultiRepo
87
88
  return true unless main_repo.ref(ref_name).merge_commit?
88
89
 
89
90
  case mode
90
- when RevisionSelectionMode::AS_LOCK
91
+ when RevisionSelection::AS_LOCK
91
92
  Console.log_error("The specified ref is a merge commit and an \"as-lock\" checkout was requested.")
92
93
  Console.log_error("The resulting checkout would most probably not result in a valid project state.")
93
94
  return false
94
- when RevisionSelectionMode::LATEST
95
+ when RevisionSelection::LATEST
95
96
  Console.log_warning("The specified ref is a merge commit and a \"latest\" checkout was requested.")
96
97
  Console.log_warning("The work branches recorded in the branch from which the merge was performed will be checked out.")
97
98
  end
@@ -65,10 +65,6 @@ module MultiRepo
65
65
  def multirepo_enabled_dependencies
66
66
  ConfigFile.new(".").load_entries.select { |e| Utils.multirepo_enabled?(e.repo.path) }
67
67
  end
68
-
69
- def validate_only_one_flag(*flags)
70
- flags.reduce(0) { |count, flag| count += 1 if flag; count } <= 1
71
- end
72
68
 
73
69
  def ensure_in_work_tree
74
70
  repo = Repo.new(".")
@@ -1,10 +1,11 @@
1
1
  require_relative "command"
2
- require "multirepo/utility/utils"
3
2
  require "multirepo/utility/console"
3
+ require "multirepo/utility/utils"
4
4
  require "multirepo/files/config-file"
5
5
  require "multirepo/git/repo"
6
6
  require "multirepo/git/git-runner"
7
7
  require "multirepo/logic/performer"
8
+ require "multirepo/logic/repo-selection"
8
9
 
9
10
  module MultiRepo
10
11
  class DoCommand < Command
@@ -22,18 +23,14 @@ module MultiRepo
22
23
 
23
24
  def initialize(argv)
24
25
  @operation = argv.shift_argument
25
- @all = argv.flag?("all")
26
- @main_only = argv.flag?("main")
27
- @deps_only = argv.flag?("deps")
26
+ @repo_selection = RepoSelection.new(argv)
28
27
  super
29
28
  end
30
29
 
31
30
  def validate!
32
31
  super
33
32
  help! "You must provide a git operation to perform" unless @operation
34
- unless validate_only_one_flag(@all, @main_only, @deps_only)
35
- help! "You can't provide more than one operation modifier (--deps, --main, etc.)"
36
- end
33
+ help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
37
34
  end
38
35
 
39
36
  def run
@@ -43,13 +40,14 @@ module MultiRepo
43
40
  @operation = @operation.sub(/^git /, "")
44
41
 
45
42
  success = true
46
- if @main_only
43
+ case @repo_selection.value
44
+ when RepoSelection::MAIN
47
45
  confirm_main_repo_operation
48
46
  success &= perform_operation_on_main(@operation)
49
- elsif @deps_only
47
+ when RepoSelection::DEPS
50
48
  confirm_dependencies_operation
51
49
  success &= perform_operation_on_dependencies(@operation)
52
- else
50
+ when RepoSelection::ALL
53
51
  confirm_main_repo_operation
54
52
  confirm_dependencies_operation
55
53
  success &= perform_operation_on_dependencies(@operation) # Ordered dependencies first
@@ -21,7 +21,7 @@ module MultiRepo
21
21
 
22
22
  def validate!
23
23
  super
24
- unless validate_only_one_flag(@version, @tracked)
24
+ unless Utils.only_one_true?(@version, @tracked)
25
25
  help! "You can't provide more than one operation modifier (--version, --tracked, etc.)"
26
26
  end
27
27
  end
@@ -26,7 +26,7 @@ module MultiRepo
26
26
 
27
27
  def validate!
28
28
  super
29
- unless validate_only_one_flag(@hooks, @ci)
29
+ unless Utils.only_one_true?(@hooks, @ci)
30
30
  help! "You can't provide more than one operation modifier (--hooks, --ci, etc.)"
31
31
  end
32
32
  end
@@ -94,7 +94,7 @@ module MultiRepo
94
94
 
95
95
  # Checkout the appropriate branches as specified in the lock file
96
96
  checkout_command = CheckoutCommand.new(CLAide::ARGV.new([]))
97
- mode = @ci ? RevisionSelectionMode::AS_LOCK : RevisionSelectionMode::LATEST
97
+ mode = @ci ? RevisionSelection::AS_LOCK : RevisionSelection::LATEST
98
98
  checkout_command.dependencies_checkout_step(mode)
99
99
  end
100
100
 
@@ -1,11 +1,14 @@
1
1
  require "terminal-table"
2
2
 
3
- require "multirepo/utility/console"
3
+ require "multirepo/utility/console"
4
+ require "multirepo/utility/utils"
4
5
  require "multirepo/logic/node"
5
6
  require "multirepo/logic/revision-selector"
7
+ require "multirepo/logic/repo-selection"
6
8
  require "multirepo/logic/performer"
7
9
  require "multirepo/logic/merge-descriptor"
8
10
  require "multirepo/files/tracking-files"
11
+ require "multirepo/commands/update-command"
9
12
 
10
13
  module MultiRepo
11
14
  class MergeValidationResult
@@ -39,7 +42,7 @@ module MultiRepo
39
42
  def validate!
40
43
  super
41
44
  help! "You must specify a ref to merge" unless @ref_name
42
- unless validate_only_one_flag(@checkout_latest, @checkout_exact)
45
+ unless Utils.only_one_true?(@checkout_latest, @checkout_exact)
43
46
  help! "You can't provide more than one operation modifier (--latest, --exact, etc.)"
44
47
  end
45
48
  end
@@ -51,7 +54,7 @@ module MultiRepo
51
54
  # Find out the checkout mode based on command-line options
52
55
  mode = RevisionSelector.mode_for_args(@checkout_latest, @checkout_exact)
53
56
 
54
- strategy_name = RevisionSelectionMode.name_for_mode(mode)
57
+ strategy_name = RevisionSelection.name_for_mode(mode)
55
58
  Console.log_step("Merging #{@ref_name} with '#{strategy_name}' strategy...")
56
59
 
57
60
  main_repo = Repo.new(".")
@@ -222,26 +225,23 @@ module MultiRepo
222
225
 
223
226
  def ask_tracking_files_update(all_merges_succeeded)
224
227
  unless all_merges_succeeded
225
- Console.log_warning("Perform a manual update using 'multi update' after resolving merge conflicts")
228
+ Console.log_warning("Perform a 'multi update' after resolving merge conflicts to ensure lock file contents are valid")
226
229
  return
227
230
  end
228
231
 
229
- return unless Console.ask("Update main repo tracking files (important for continuous integration)?")
232
+ return unless Console.ask("Update main repo tracking files? (important for continuous integration)")
230
233
 
231
- tracking_files = TrackingFiles.new(".")
232
- tracking_files.update
233
- tracking_files.commit("[multirepo] Post-merge tracking files update")
234
-
235
- Console.log_info("Updated and committed tracking files in the main repo")
234
+ update_command = UpdateCommand.new(CLAide::ARGV.new(["--commit", "--diff"]))
235
+ update_command.update_tracking_files_step(RepoSelection::MAIN)
236
236
  end
237
237
 
238
238
  def message_for_mode(mode, ref_name)
239
239
  case mode
240
- when RevisionSelectionMode::AS_LOCK
240
+ when RevisionSelection::AS_LOCK
241
241
  "merge specific commits as stored in the lock file for main repo revision #{ref_name}"
242
- when RevisionSelectionMode::LATEST
242
+ when RevisionSelection::LATEST
243
243
  "merge each branch as stored in the lock file of main repo revision #{ref_name}"
244
- when RevisionSelectionMode::EXACT
244
+ when RevisionSelection::EXACT
245
245
  "merge #{ref_name} for each repository, ignoring the contents of the lock file"
246
246
  end
247
247
  end
@@ -2,6 +2,7 @@ require "os"
2
2
 
3
3
  require "multirepo/utility/console"
4
4
  require "multirepo/utility/utils"
5
+ require "multirepo/logic/repo-selection"
5
6
 
6
7
  module MultiRepo
7
8
  class OpenCommand < Command
@@ -17,28 +18,25 @@ module MultiRepo
17
18
  end
18
19
 
19
20
  def initialize(argv)
20
- @all = argv.flag?("all")
21
- @main_only = argv.flag?("main")
22
- @deps_only = argv.flag?("deps")
21
+ @repo_selection = RepoSelection.new(argv)
23
22
  super
24
23
  end
25
24
 
26
25
  def validate!
27
26
  super
28
- unless validate_only_one_flag(@all, @main_only, @deps_only)
29
- help! "You can't provide more than one operation modifier (--deps, --main, etc.)"
30
- end
27
+ help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
31
28
  end
32
29
 
33
30
  def run
34
31
  ensure_in_work_tree
35
32
  ensure_multirepo_enabled
36
33
 
37
- if @main_only
34
+ case @repo_selection.value
35
+ when RepoSelection::MAIN
38
36
  open_main
39
- elsif @deps_only
37
+ when RepoSelection::DEPS
40
38
  open_dependencies
41
- else
39
+ when RepoSelection::ALL
42
40
  open_dependencies
43
41
  open_main
44
42
  end
@@ -1,5 +1,7 @@
1
1
  require "multirepo/utility/console"
2
+ require "multirepo/utility/utils"
2
3
  require "multirepo/logic/performer"
4
+ require "multirepo/logic/repo-selection"
3
5
  require "multirepo/files/tracking-files"
4
6
  require "multirepo/git/git-runner"
5
7
 
@@ -14,24 +16,22 @@ module MultiRepo
14
16
  ['[--main]', 'Update the main repository.'],
15
17
  ['[--deps]', 'Update dependencies.'],
16
18
  ['[--force]', 'Update the tracking files even if dependencies contain uncommitted changes.'],
17
- ['[--commit]', 'Commit the tracking files after updating them.']
19
+ ['[--commit]', 'Commit the tracking files after updating them.'],
20
+ ['[--no-diff]', 'Don\'t show lock file diff(s) after updating.']
18
21
  ].concat(super)
19
22
  end
20
23
 
21
24
  def initialize(argv)
22
- @all = argv.flag?("all")
23
- @main_only = argv.flag?("main")
24
- @deps_only = argv.flag?("deps")
25
+ @repo_selection = RepoSelection.new(argv)
25
26
  @commit = argv.flag?("commit")
26
27
  @force = argv.flag?("force")
28
+ @diff = argv.flag?("diff", true)
27
29
  super
28
30
  end
29
31
 
30
32
  def validate!
31
33
  super
32
- unless validate_only_one_flag(@all, @main_only, @deps_only)
33
- help! "You can't provide more than one operation modifier (--deps, --main, etc.)"
34
- end
34
+ help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
35
35
  end
36
36
 
37
37
  def run
@@ -40,7 +40,7 @@ module MultiRepo
40
40
 
41
41
  dependencies_clean = Utils.dependencies_clean?(ConfigFile.new(".").load_entries)
42
42
  if dependencies_clean || @force
43
- update_tracking_files_step
43
+ update_tracking_files_step(@repo_selection.value)
44
44
  else
45
45
  fail MultiRepoException, "Can't update because not all dependencies are clean"
46
46
  end
@@ -48,21 +48,19 @@ module MultiRepo
48
48
  Console.log_step("Done!")
49
49
  end
50
50
 
51
- def update_tracking_files_step
52
- main_changed = false
53
- if @main_only
51
+ def update_tracking_files_step(repo_selection_value)
52
+ case repo_selection_value
53
+ when RepoSelection::MAIN
54
54
  Console.log_step("Updating main repo...")
55
- main_changed = update_main
56
- elsif @deps_only
55
+ update_main
56
+ when RepoSelection::DEPS
57
57
  Console.log_step("Updating dependencies...")
58
58
  update_dependencies
59
- else
59
+ when RepoSelection::ALL
60
60
  Console.log_step("Updating main repo and dependencies...")
61
61
  update_dependencies
62
- main_changed = update_main
62
+ update_main
63
63
  end
64
-
65
- show_diff(".") if main_changed && Console.ask("Show diff?")
66
64
  end
67
65
 
68
66
  def update_dependencies
@@ -70,13 +68,20 @@ module MultiRepo
70
68
  Performer.dependencies.each do |dependency|
71
69
  path = dependency.config_entry.path
72
70
  name = dependency.config_entry.name
73
- any_changed |= update_tracking_files(path, name) if Utils.multirepo_enabled?(path)
71
+ any_changed |= update_one(path, name) if Utils.multirepo_enabled?(path)
74
72
  end
75
73
  return any_changed
76
74
  end
77
75
 
78
76
  def update_main
79
- return update_tracking_files(".", "main repo")
77
+ update_one(".", "main repo")
78
+ end
79
+
80
+ def update_one(path, name)
81
+ updated = update_tracking_files(path, name)
82
+ show_diff(path) if updated && @diff
83
+ commit_tracking_files(path) if @commit
84
+ return updated
80
85
  end
81
86
 
82
87
  def update_tracking_files(path, name)
@@ -91,14 +96,15 @@ module MultiRepo
91
96
  Console.log_info("Tracking files are already up-to-date")
92
97
  end
93
98
 
94
- if @commit
95
- committed = tracking_files.commit("[multirepo] Updated tracking files manually")
96
- Console.log_info("Committed tracking files") if committed
97
- end
98
-
99
99
  return changed
100
100
  end
101
101
 
102
+ def commit_tracking_files(path)
103
+ tracking_files = TrackingFiles.new(path)
104
+ committed = tracking_files.commit("[multirepo] Updated tracking files manually")
105
+ Console.log_info("Committed tracking files") if committed
106
+ end
107
+
102
108
  def show_diff(path)
103
109
  GitRunner.run_as_system(path, "diff .multirepo.lock")
104
110
  end
@@ -1,5 +1,5 @@
1
1
  module MultiRepo
2
2
  NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta50"
3
+ VERSION = "1.0.0.beta51"
4
4
  DESCRIPTION = "Track multiple Git repositories side-by-side."
5
5
  end
@@ -0,0 +1,25 @@
1
+ require "multirepo/utility/utils"
2
+
3
+ module MultiRepo
4
+ class RepoSelection
5
+ ALL = 0
6
+ MAIN = 1
7
+ DEPS = 2
8
+
9
+ def initialize(argv)
10
+ @main = argv.flag?("main")
11
+ @deps = argv.flag?("deps")
12
+ @all = argv.flag?("all")
13
+ end
14
+
15
+ def valid?
16
+ Utils.only_one_true?(@main, @deps, @all)
17
+ end
18
+
19
+ def value
20
+ return MAIN if @main
21
+ return DEPS if @deps
22
+ return ALL # Default if unspecified
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module MultiRepo
2
+ class RevisionSelection
3
+ AS_LOCK = 0
4
+ LATEST = 1
5
+ EXACT = 2
6
+
7
+ def self.name_for_mode(mode)
8
+ case mode
9
+ when AS_LOCK then "as-lock"
10
+ when LATEST then "latest"
11
+ when EXACT then "exact"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,34 +1,22 @@
1
+ require_relative "revision-selection"
2
+
1
3
  module MultiRepo
2
- class RevisionSelectionMode
3
- AS_LOCK = 0
4
- LATEST = 1
5
- EXACT = 2
6
-
7
- def self.name_for_mode(mode)
8
- case mode
9
- when AS_LOCK then "as-lock"
10
- when LATEST then "latest"
11
- when EXACT then "exact"
12
- end
13
- end
14
- end
15
-
16
4
  class RevisionSelector
17
5
  def self.mode_for_args(checkout_latest, checkout_exact)
18
6
  if checkout_latest
19
- RevisionSelectionMode::LATEST
7
+ RevisionSelection::LATEST
20
8
  elsif checkout_exact
21
- RevisionSelectionMode::EXACT
9
+ RevisionSelection::EXACT
22
10
  else
23
- RevisionSelectionMode::AS_LOCK
11
+ RevisionSelection::AS_LOCK
24
12
  end
25
13
  end
26
14
 
27
15
  def self.revision_for_mode(mode, ref_name, lock_entry)
28
16
  case mode
29
- when RevisionSelectionMode::AS_LOCK then lock_entry.head
30
- when RevisionSelectionMode::LATEST then lock_entry.branch
31
- when RevisionSelectionMode::EXACT then ref_name
17
+ when RevisionSelection::AS_LOCK then lock_entry.head
18
+ when RevisionSelection::LATEST then lock_entry.branch
19
+ when RevisionSelection::EXACT then ref_name
32
20
  end
33
21
  end
34
22
  end
@@ -3,6 +3,10 @@ require "fileutils"
3
3
 
4
4
  module MultiRepo
5
5
  class Utils
6
+ def self.only_one_true?(*flags)
7
+ flags.reduce(0) { |count, flag| count += 1 if flag; count } <= 1
8
+ end
9
+
6
10
  def self.path_for_resource(resource_name)
7
11
  gem_path = Gem::Specification.find_by_name("git-multirepo").gem_dir
8
12
  File.join(gem_path, "resources/#{resource_name}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-multirepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta50
4
+ version: 1.0.0.beta51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Fortin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -197,6 +197,8 @@ files:
197
197
  - lib/multirepo/logic/merge-descriptor.rb
198
198
  - lib/multirepo/logic/node.rb
199
199
  - lib/multirepo/logic/performer.rb
200
+ - lib/multirepo/logic/repo-selection.rb
201
+ - lib/multirepo/logic/revision-selection.rb
200
202
  - lib/multirepo/logic/revision-selector.rb
201
203
  - lib/multirepo/multirepo-exception.rb
202
204
  - lib/multirepo/utility/console.rb