git-multirepo 1.0.0.beta49 → 1.0.0.beta50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) 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.meta +2 -2
  6. data/.rspec +2 -2
  7. data/.rubocop.yml +79 -79
  8. data/CHANGELOG.md +29 -25
  9. data/Gemfile +4 -4
  10. data/Gemfile.lock +42 -42
  11. data/LICENSE +22 -22
  12. data/README.md +154 -154
  13. data/Rakefile +1 -1
  14. data/bin/multi +11 -11
  15. data/docs/bug-repros/91565510-repro.sh +20 -20
  16. data/git-multirepo.gemspec +31 -31
  17. data/lib/git-multirepo.rb +3 -3
  18. data/lib/multirepo/commands/add-command.rb +51 -51
  19. data/lib/multirepo/commands/branch-command.rb +82 -82
  20. data/lib/multirepo/commands/checkout-command.rb +120 -120
  21. data/lib/multirepo/commands/clone-command.rb +68 -68
  22. data/lib/multirepo/commands/command.rb +90 -90
  23. data/lib/multirepo/commands/commands.rb +15 -0
  24. data/lib/multirepo/commands/do-command.rb +103 -103
  25. data/lib/multirepo/commands/graph-command.rb +43 -43
  26. data/lib/multirepo/commands/init-command.rb +121 -121
  27. data/lib/multirepo/commands/inspect-command.rb +39 -39
  28. data/lib/multirepo/commands/install-command.rb +153 -153
  29. data/lib/multirepo/commands/merge-command.rb +249 -225
  30. data/lib/multirepo/commands/open-command.rb +57 -57
  31. data/lib/multirepo/commands/remove-command.rb +48 -48
  32. data/lib/multirepo/commands/uninit-command.rb +18 -18
  33. data/lib/multirepo/commands/update-command.rb +106 -94
  34. data/lib/multirepo/config.rb +16 -16
  35. data/lib/multirepo/files/config-entry.rb +39 -39
  36. data/lib/multirepo/files/config-file.rb +46 -46
  37. data/lib/multirepo/files/lock-entry.rb +29 -29
  38. data/lib/multirepo/files/lock-file.rb +56 -56
  39. data/lib/multirepo/files/meta-file.rb +41 -41
  40. data/lib/multirepo/files/tracking-file.rb +9 -9
  41. data/lib/multirepo/files/tracking-files.rb +47 -47
  42. data/lib/multirepo/git/branch.rb +32 -32
  43. data/lib/multirepo/git/change.rb +11 -11
  44. data/lib/multirepo/git/commit.rb +7 -7
  45. data/lib/multirepo/git/git-runner.rb +56 -56
  46. data/lib/multirepo/git/git.rb +10 -10
  47. data/lib/multirepo/git/ref.rb +38 -38
  48. data/lib/multirepo/git/remote.rb +17 -17
  49. data/lib/multirepo/git/repo.rb +124 -124
  50. data/lib/multirepo/hooks/post-commit-hook.rb +23 -23
  51. data/lib/multirepo/hooks/pre-commit-hook.rb +35 -35
  52. data/lib/{info.rb → multirepo/info.rb} +5 -5
  53. data/lib/multirepo/logic/dependency.rb +6 -6
  54. data/lib/multirepo/logic/merge-descriptor.rb +95 -95
  55. data/lib/multirepo/logic/node.rb +72 -72
  56. data/lib/multirepo/logic/performer.rb +55 -55
  57. data/lib/multirepo/logic/revision-selector.rb +35 -35
  58. data/lib/multirepo/multirepo-exception.rb +6 -6
  59. data/lib/multirepo/utility/console.rb +52 -52
  60. data/lib/multirepo/utility/popen-runner.rb +27 -27
  61. data/lib/multirepo/utility/system-runner.rb +14 -14
  62. data/lib/multirepo/utility/utils.rb +95 -95
  63. data/lib/multirepo/utility/verbosity.rb +6 -6
  64. data/resources/.gitconfig +2 -2
  65. data/resources/post-commit +6 -6
  66. data/resources/pre-commit +6 -6
  67. data/spec/integration/init_spec.rb +19 -19
  68. data/spec/spec_helper.rb +89 -89
  69. metadata +33 -33
  70. data/lib/commands.rb +0 -15
@@ -1,57 +1,57 @@
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 repositories in the OS's file explorer."
10
-
11
- def self.options
12
- [
13
- ['[--all]', 'Open the main repository and all dependencies.'],
14
- ['[--main]', 'Open the main repository.'],
15
- ['[--deps]', 'Open dependencies.']
16
- ].concat(super)
17
- end
18
-
19
- def initialize(argv)
20
- @all = argv.flag?("all")
21
- @main_only = argv.flag?("main")
22
- @deps_only = argv.flag?("deps")
23
- super
24
- end
25
-
26
- def validate!
27
- 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
31
- end
32
-
33
- def run
34
- ensure_in_work_tree
35
- ensure_multirepo_enabled
36
-
37
- if @main_only
38
- open_main
39
- elsif @deps_only
40
- open_dependencies
41
- else
42
- open_dependencies
43
- open_main
44
- end
45
- end
46
-
47
- def open_main
48
- Utils.reveal_in_default_file_browser(".")
49
- end
50
-
51
- def open_dependencies
52
- ConfigFile.new(".").load_entries.each do |entry|
53
- Utils.reveal_in_default_file_browser(entry.repo.path)
54
- end
55
- end
56
- end
57
- 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 repositories in the OS's file explorer."
10
+
11
+ def self.options
12
+ [
13
+ ['[--all]', 'Open the main repository and all dependencies.'],
14
+ ['[--main]', 'Open the main repository.'],
15
+ ['[--deps]', 'Open dependencies.']
16
+ ].concat(super)
17
+ end
18
+
19
+ def initialize(argv)
20
+ @all = argv.flag?("all")
21
+ @main_only = argv.flag?("main")
22
+ @deps_only = argv.flag?("deps")
23
+ super
24
+ end
25
+
26
+ def validate!
27
+ 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
31
+ end
32
+
33
+ def run
34
+ ensure_in_work_tree
35
+ ensure_multirepo_enabled
36
+
37
+ if @main_only
38
+ open_main
39
+ elsif @deps_only
40
+ open_dependencies
41
+ else
42
+ open_dependencies
43
+ open_main
44
+ end
45
+ end
46
+
47
+ def open_main
48
+ Utils.reveal_in_default_file_browser(".")
49
+ end
50
+
51
+ def open_dependencies
52
+ ConfigFile.new(".").load_entries.each do |entry|
53
+ Utils.reveal_in_default_file_browser(entry.repo.path)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,48 +1,48 @@
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 self.options
10
- [
11
- ['<path>', 'The relative path to the dependency to remove (e.g. ../MyOldDependency).'],
12
- ['[--delete]', 'Delete the dependency on disk in addition to removing it from the multirepo config.']
13
- ].concat(super)
14
- end
15
-
16
- def initialize(argv)
17
- @path = argv.shift_argument
18
- @delete = argv.flag?("delete")
19
- super
20
- end
21
-
22
- def validate!
23
- super
24
- help! "You must specify a dependency repository to remove" unless @path
25
- end
26
-
27
- def run
28
- ensure_in_work_tree
29
- ensure_multirepo_enabled
30
-
31
- repo = Repo.new(@path)
32
- entry = ConfigEntry.new(repo)
33
-
34
- config_file = ConfigFile.new(".")
35
- if config_file.entry_exists?(entry)
36
- config_file.remove_entry(entry)
37
- Console.log_step("Removed '#{@path}' from the .multirepo file")
38
-
39
- if @delete
40
- FileUtils.rm_rf(@path)
41
- Console.log_step("Deleted '#{@path}' from disk")
42
- end
43
- else
44
- fail MultiRepoException, "'#{@path}' isn't tracked by multirepo"
45
- end
46
- end
47
- end
48
- 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 self.options
10
+ [
11
+ ['<path>', 'The relative path to the dependency to remove (e.g. ../MyOldDependency).'],
12
+ ['[--delete]', 'Delete the dependency on disk in addition to removing it from the multirepo config.']
13
+ ].concat(super)
14
+ end
15
+
16
+ def initialize(argv)
17
+ @path = argv.shift_argument
18
+ @delete = argv.flag?("delete")
19
+ super
20
+ end
21
+
22
+ def validate!
23
+ super
24
+ help! "You must specify a dependency repository to remove" unless @path
25
+ end
26
+
27
+ def run
28
+ ensure_in_work_tree
29
+ ensure_multirepo_enabled
30
+
31
+ repo = Repo.new(@path)
32
+ entry = ConfigEntry.new(repo)
33
+
34
+ config_file = ConfigFile.new(".")
35
+ if config_file.entry_exists?(entry)
36
+ config_file.remove_entry(entry)
37
+ Console.log_step("Removed '#{@path}' from the .multirepo file")
38
+
39
+ if @delete
40
+ FileUtils.rm_rf(@path)
41
+ Console.log_step("Deleted '#{@path}' from disk")
42
+ end
43
+ else
44
+ fail MultiRepoException, "'#{@path}' isn't tracked by multirepo"
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,18 +1,18 @@
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
- ensure_in_work_tree
10
-
11
- FileUtils.rm_f(".multirepo")
12
- TrackingFiles.new(".").delete
13
- uninstall_hooks
14
-
15
- Console.log_step("All traces of multirepo have been removed from this repository")
16
- end
17
- end
18
- 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
+ ensure_in_work_tree
10
+
11
+ FileUtils.rm_f(".multirepo")
12
+ TrackingFiles.new(".").delete
13
+ uninstall_hooks
14
+
15
+ Console.log_step("All traces of multirepo have been removed from this repository")
16
+ end
17
+ end
18
+ end
@@ -1,94 +1,106 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/logic/performer"
3
- require "multirepo/files/tracking-files"
4
-
5
- module MultiRepo
6
- class UpdateCommand < Command
7
- self.command = "update"
8
- self.summary = "Force-updates the multirepo tracking files."
9
-
10
- def self.options
11
- [
12
- ['[--all]', 'Update the main repository and all dependencies.'],
13
- ['[--main]', 'Update the main repository.'],
14
- ['[--deps]', 'Update dependencies.'],
15
- ['[--force]', 'Update the tracking files even if dependencies contain uncommitted changes.'],
16
- ['[--commit]', 'Commit the tracking files after updating them.']
17
- ].concat(super)
18
- end
19
-
20
- def initialize(argv)
21
- @all = argv.flag?("all")
22
- @main_only = argv.flag?("main")
23
- @deps_only = argv.flag?("deps")
24
- @commit = argv.flag?("commit")
25
- @force = argv.flag?("force")
26
- super
27
- end
28
-
29
- def validate!
30
- super
31
- unless validate_only_one_flag(@all, @main_only, @deps_only)
32
- help! "You can't provide more than one operation modifier (--deps, --main, etc.)"
33
- end
34
- end
35
-
36
- def run
37
- ensure_in_work_tree
38
- ensure_multirepo_enabled
39
-
40
- dependencies_clean = Utils.dependencies_clean?(ConfigFile.new(".").load_entries)
41
- if dependencies_clean || @force
42
- update_tracking_files_step
43
- else
44
- fail MultiRepoException, "Can't update because not all dependencies are clean"
45
- end
46
-
47
- Console.log_step("Done!")
48
- end
49
-
50
- def update_tracking_files_step
51
- if @main_only
52
- Console.log_step("Updating main repo...")
53
- update_main
54
- elsif @deps_only
55
- Console.log_step("Updating dependencies...")
56
- update_dependencies
57
- else
58
- Console.log_step("Updating main repo and dependencies...")
59
- update_dependencies
60
- update_main
61
- end
62
- end
63
-
64
- def update_dependencies
65
- Performer.dependencies.each do |dependency|
66
- path = dependency.config_entry.path
67
- name = dependency.config_entry.name
68
- update_tracking_files(path, name) if Utils.multirepo_enabled?(path)
69
- end
70
- end
71
-
72
- def update_main
73
- update_tracking_files(".", "main repo")
74
- end
75
-
76
- def update_tracking_files(path, name)
77
- Console.log_substep("Updating tracking files in #{name}")
78
-
79
- tracking_files = TrackingFiles.new(path)
80
- changed = tracking_files.update
81
-
82
- if changed
83
- Console.log_info("Updated tracking files")
84
- else
85
- Console.log_info("Tracking files are already up-to-date")
86
- end
87
-
88
- if @commit
89
- committed = tracking_files.commit("[multirepo] Updated tracking files manually")
90
- Console.log_info("Committed tracking files") if committed
91
- end
92
- end
93
- end
94
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/logic/performer"
3
+ require "multirepo/files/tracking-files"
4
+ require "multirepo/git/git-runner"
5
+
6
+ module MultiRepo
7
+ class UpdateCommand < Command
8
+ self.command = "update"
9
+ self.summary = "Force-updates the multirepo tracking files."
10
+
11
+ def self.options
12
+ [
13
+ ['[--all]', 'Update the main repository and all dependencies.'],
14
+ ['[--main]', 'Update the main repository.'],
15
+ ['[--deps]', 'Update dependencies.'],
16
+ ['[--force]', 'Update the tracking files even if dependencies contain uncommitted changes.'],
17
+ ['[--commit]', 'Commit the tracking files after updating them.']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @all = argv.flag?("all")
23
+ @main_only = argv.flag?("main")
24
+ @deps_only = argv.flag?("deps")
25
+ @commit = argv.flag?("commit")
26
+ @force = argv.flag?("force")
27
+ super
28
+ end
29
+
30
+ def validate!
31
+ 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
35
+ end
36
+
37
+ def run
38
+ ensure_in_work_tree
39
+ ensure_multirepo_enabled
40
+
41
+ dependencies_clean = Utils.dependencies_clean?(ConfigFile.new(".").load_entries)
42
+ if dependencies_clean || @force
43
+ update_tracking_files_step
44
+ else
45
+ fail MultiRepoException, "Can't update because not all dependencies are clean"
46
+ end
47
+
48
+ Console.log_step("Done!")
49
+ end
50
+
51
+ def update_tracking_files_step
52
+ main_changed = false
53
+ if @main_only
54
+ Console.log_step("Updating main repo...")
55
+ main_changed = update_main
56
+ elsif @deps_only
57
+ Console.log_step("Updating dependencies...")
58
+ update_dependencies
59
+ else
60
+ Console.log_step("Updating main repo and dependencies...")
61
+ update_dependencies
62
+ main_changed = update_main
63
+ end
64
+
65
+ show_diff(".") if main_changed && Console.ask("Show diff?")
66
+ end
67
+
68
+ def update_dependencies
69
+ any_changed = false
70
+ Performer.dependencies.each do |dependency|
71
+ path = dependency.config_entry.path
72
+ name = dependency.config_entry.name
73
+ any_changed |= update_tracking_files(path, name) if Utils.multirepo_enabled?(path)
74
+ end
75
+ return any_changed
76
+ end
77
+
78
+ def update_main
79
+ return update_tracking_files(".", "main repo")
80
+ end
81
+
82
+ def update_tracking_files(path, name)
83
+ Console.log_substep("Updating tracking files in #{name}")
84
+
85
+ tracking_files = TrackingFiles.new(path)
86
+ changed = tracking_files.update
87
+
88
+ if changed
89
+ Console.log_info("Updated tracking files")
90
+ else
91
+ Console.log_info("Tracking files are already up-to-date")
92
+ end
93
+
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
+ return changed
100
+ end
101
+
102
+ def show_diff(path)
103
+ GitRunner.run_as_system(path, "diff .multirepo.lock")
104
+ end
105
+ end
106
+ end
@@ -1,16 +1,16 @@
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
-
13
- attr_accessor :git_executable
14
- @git_executable = nil
15
- end
16
- 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
+
13
+ attr_accessor :git_executable
14
+ @git_executable = nil
15
+ end
16
+ end