git-multirepo 1.0.0.beta21 → 1.0.0.beta24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +38 -38
  3. data/.rspec +2 -2
  4. data/Gemfile +4 -4
  5. data/Gemfile.lock +37 -37
  6. data/LICENSE +22 -22
  7. data/README.md +141 -139
  8. data/Rakefile +2 -2
  9. data/bin/multi +10 -10
  10. data/docs/git-multirepo-cheatsheet.docx +0 -0
  11. data/git-multirepo.gemspec +29 -29
  12. data/lib/commands.rb +11 -11
  13. data/lib/git-multirepo.rb +2 -2
  14. data/lib/info.rb +4 -4
  15. data/lib/multirepo/commands/add-command.rb +51 -51
  16. data/lib/multirepo/commands/branch-command.rb +52 -52
  17. data/lib/multirepo/commands/checkout-command.rb +119 -119
  18. data/lib/multirepo/commands/clone-command.rb +69 -69
  19. data/lib/multirepo/commands/command.rb +58 -50
  20. data/lib/multirepo/commands/fetch-command.rb +23 -23
  21. data/lib/multirepo/commands/init-command.rb +51 -51
  22. data/lib/multirepo/commands/install-command.rb +87 -87
  23. data/lib/multirepo/commands/open-command.rb +25 -25
  24. data/lib/multirepo/commands/remove-command.rb +48 -48
  25. data/lib/multirepo/commands/uninit-command.rb +20 -20
  26. data/lib/multirepo/commands/update-command.rb +47 -47
  27. data/lib/multirepo/config.rb +15 -12
  28. data/lib/multirepo/files/config-entry.rb +34 -34
  29. data/lib/multirepo/files/config-file.rb +37 -37
  30. data/lib/multirepo/files/lock-entry.rb +25 -25
  31. data/lib/multirepo/files/lock-file.rb +39 -39
  32. data/lib/multirepo/git/branch.rb +27 -27
  33. data/lib/multirepo/git/change.rb +10 -10
  34. data/lib/multirepo/git/git.rb +42 -38
  35. data/lib/multirepo/git/remote.rb +15 -15
  36. data/lib/multirepo/git/repo.rb +66 -66
  37. data/lib/multirepo/hooks/post-merge-hook.rb +19 -19
  38. data/lib/multirepo/hooks/pre-commit-hook.rb +25 -25
  39. data/lib/multirepo/hooks/prepare-commit-msg-hook.rb +27 -27
  40. data/lib/multirepo/multirepo-exception.rb +5 -5
  41. data/lib/multirepo/utility/console.rb +51 -51
  42. data/lib/multirepo/utility/runner.rb +32 -32
  43. data/lib/multirepo/utility/utils.rb +51 -51
  44. data/resources/post-merge +5 -5
  45. data/resources/pre-commit +5 -5
  46. data/resources/prepare-commit-msg +5 -5
  47. data/spec/integration/init_spec.rb +22 -22
  48. data/spec/spec_helper.rb +89 -89
  49. metadata +4 -3
@@ -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
- validate_in_work_tree
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
+ validate_in_work_tree
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,49 +1,49 @@
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
- validate_in_work_tree
29
- ensure_multirepo_initialized
30
-
31
- repo = Repo.new(@path)
32
- entry = ConfigEntry.new(repo)
33
-
34
- if ConfigFile.entry_exists?(entry)
35
- ConfigFile.remove_entry(entry)
36
- Console.log_step("Removed '#{@path}' from the .multirepo file")
37
-
38
- if @delete
39
- FileUtils.rm_rf(@path)
40
- Console.log_step("Deleted '#{@path}' from disk")
41
- end
42
- else
43
- raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
44
- end
45
- rescue MultiRepoException => e
46
- Console.log_error(e.message)
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
+ validate_in_work_tree
29
+ ensure_multirepo_initialized
30
+
31
+ repo = Repo.new(@path)
32
+ entry = ConfigEntry.new(repo)
33
+
34
+ if ConfigFile.entry_exists?(entry)
35
+ ConfigFile.remove_entry(entry)
36
+ Console.log_step("Removed '#{@path}' from the .multirepo file")
37
+
38
+ if @delete
39
+ FileUtils.rm_rf(@path)
40
+ Console.log_step("Deleted '#{@path}' from disk")
41
+ end
42
+ else
43
+ raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
44
+ end
45
+ rescue MultiRepoException => e
46
+ Console.log_error(e.message)
47
+ end
48
+ end
49
49
  end
@@ -1,21 +1,21 @@
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
- validate_in_work_tree
10
- ensure_multirepo_initialized
11
-
12
- File.delete(".multirepo")
13
- File.delete(".multirepo.lock")
14
- uninstall_hooks
15
-
16
- Console.log_step("All traces of multirepo have been removed from this repository")
17
- rescue MultiRepoException => e
18
- Console.log_error(e.message)
19
- end
20
- 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
+ validate_in_work_tree
10
+ ensure_multirepo_initialized
11
+
12
+ File.delete(".multirepo")
13
+ File.delete(".multirepo.lock")
14
+ uninstall_hooks
15
+
16
+ Console.log_step("All traces of multirepo have been removed from this repository")
17
+ rescue MultiRepoException => e
18
+ Console.log_error(e.message)
19
+ end
20
+ end
21
21
  end
@@ -1,48 +1,48 @@
1
- require "multirepo/utility/console"
2
-
3
- module MultiRepo
4
- class UpdateCommand < Command
5
- self.command = "update"
6
- self.summary = "Force-updates the multirepo lock file."
7
-
8
- def self.options
9
- [
10
- ['--force', 'Update the lock file even if dependencies contain uncommitted changes.'],
11
- ['--commit', 'Commit the lock file after updating it.']
12
- ].concat(super)
13
- end
14
-
15
- def initialize(argv)
16
- @commit = argv.flag?("commit")
17
- @force = argv.flag?("force")
18
- super
19
- end
20
-
21
- def run
22
- validate_in_work_tree
23
- ensure_multirepo_initialized
24
-
25
- Console.log_step("Updating...")
26
-
27
- dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
28
- if dependencies_clean
29
- LockFile.update
30
- Console.log_substep("Updated lock file with latest dependency commits")
31
- elsif !dependencies_clean && @force
32
- LockFile.update
33
- Console.log_warning("Updated lock file with latest dependency commits regardless of uncommitted changes")
34
- else
35
- raise MultiRepoException, "Can't update because not all dependencies are clean"
36
- end
37
-
38
- if @commit
39
- Console.log_substep("Committing updated lock file")
40
- LockFile.commit
41
- end
42
-
43
- Console.log_step("Done!")
44
- rescue MultiRepoException => e
45
- Console.log_error(e.message)
46
- end
47
- end
1
+ require "multirepo/utility/console"
2
+
3
+ module MultiRepo
4
+ class UpdateCommand < Command
5
+ self.command = "update"
6
+ self.summary = "Force-updates the multirepo lock file."
7
+
8
+ def self.options
9
+ [
10
+ ['[--force]', 'Update the lock file even if dependencies contain uncommitted changes.'],
11
+ ['[--commit]', 'Commit the lock file after updating it.']
12
+ ].concat(super)
13
+ end
14
+
15
+ def initialize(argv)
16
+ @commit = argv.flag?("commit")
17
+ @force = argv.flag?("force")
18
+ super
19
+ end
20
+
21
+ def run
22
+ validate_in_work_tree
23
+ ensure_multirepo_initialized
24
+
25
+ Console.log_step("Updating...")
26
+
27
+ dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
28
+ if dependencies_clean
29
+ LockFile.update
30
+ Console.log_substep("Updated lock file with latest dependency commits")
31
+ elsif !dependencies_clean && @force
32
+ LockFile.update
33
+ Console.log_warning("Updated lock file with latest dependency commits regardless of uncommitted changes")
34
+ else
35
+ raise MultiRepoException, "Can't update because not all dependencies are clean"
36
+ end
37
+
38
+ if @commit
39
+ Console.log_substep("Committing updated lock file")
40
+ LockFile.commit
41
+ end
42
+
43
+ Console.log_step("Done!")
44
+ rescue MultiRepoException => e
45
+ Console.log_error(e.message)
46
+ end
47
+ end
48
48
  end
@@ -1,13 +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
- 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
13
16
  end
@@ -1,35 +1,35 @@
1
- require "securerandom"
2
-
3
- require "multirepo/utility/console"
4
- require "multirepo/git/repo"
5
-
6
- module MultiRepo
7
- class ConfigEntry
8
- attr_accessor :id
9
- attr_accessor :path
10
- attr_accessor :url
11
- attr_accessor :repo
12
-
13
- def encode_with(coder)
14
- coder["id"] = @id
15
- coder["path"] = @path
16
- coder["url"] = @url
17
- end
18
-
19
- def ==(entry)
20
- entry_path = Pathname.new(entry.path)
21
- self_path = Pathname.new(self.path)
22
- entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
23
- end
24
-
25
- def initialize(repo)
26
- @id = SecureRandom.uuid
27
- @path = repo.path
28
- @url = repo.exists? ? repo.remote('origin').url : nil
29
- end
30
-
31
- def repo
32
- Repo.new(path)
33
- end
34
- end
1
+ require "securerandom"
2
+
3
+ require "multirepo/utility/console"
4
+ require "multirepo/git/repo"
5
+
6
+ module MultiRepo
7
+ class ConfigEntry
8
+ attr_accessor :id
9
+ attr_accessor :path
10
+ attr_accessor :url
11
+ attr_accessor :repo
12
+
13
+ def encode_with(coder)
14
+ coder["id"] = @id
15
+ coder["path"] = @path
16
+ coder["url"] = @url
17
+ end
18
+
19
+ def ==(entry)
20
+ entry_path = Pathname.new(entry.path)
21
+ self_path = Pathname.new(self.path)
22
+ entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
23
+ end
24
+
25
+ def initialize(repo)
26
+ @id = SecureRandom.uuid
27
+ @path = repo.path
28
+ @url = repo.exists? ? repo.remote('origin').url : nil
29
+ end
30
+
31
+ def repo
32
+ Repo.new(path)
33
+ end
34
+ end
35
35
  end
@@ -1,38 +1,38 @@
1
- require "fileutils"
2
- require "pathname"
3
-
4
- require_relative "config-entry"
5
-
6
- module MultiRepo
7
- class ConfigFile
8
- FILE = Pathname.new(".multirepo")
9
-
10
- def self.exists?
11
- FILE.exist?
12
- end
13
-
14
- def self.load
15
- Psych.load(FILE.read)
16
- end
17
-
18
- def self.save(entries)
19
- File.write(FILE.to_s, Psych.dump(entries))
20
- end
21
-
22
- def self.entry_exists?(entry)
23
- load.any? { |e| e == entry }
24
- end
25
-
26
- def self.add_entry(entry)
27
- save(load.push(entry))
28
- end
29
-
30
- def self.remove_entry(entry)
31
- save(load.delete_if { |e| e == entry })
32
- end
33
-
34
- def self.stage
35
- Git.run_in_current_dir("add -A -f #{FILE.to_s}", Runner::Verbosity::NEVER_OUTPUT)
36
- end
37
- end
1
+ require "fileutils"
2
+ require "pathname"
3
+
4
+ require_relative "config-entry"
5
+
6
+ module MultiRepo
7
+ class ConfigFile
8
+ FILE = Pathname.new(".multirepo")
9
+
10
+ def self.exists?
11
+ FILE.exist?
12
+ end
13
+
14
+ def self.load
15
+ Psych.load(FILE.read)
16
+ end
17
+
18
+ def self.save(entries)
19
+ File.write(FILE.to_s, Psych.dump(entries))
20
+ end
21
+
22
+ def self.entry_exists?(entry)
23
+ load.any? { |e| e == entry }
24
+ end
25
+
26
+ def self.add_entry(entry)
27
+ save(load.push(entry))
28
+ end
29
+
30
+ def self.remove_entry(entry)
31
+ save(load.delete_if { |e| e == entry })
32
+ end
33
+
34
+ def self.stage
35
+ Git.run_in_current_dir("add -A -f #{FILE.to_s}", Runner::Verbosity::NEVER_OUTPUT)
36
+ end
37
+ end
38
38
  end