git-multirepo 1.0.0.beta34 → 1.0.0.beta37

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -2
  3. data/.gitignore +38 -38
  4. data/.multirepo.meta +2 -2
  5. data/.rspec +2 -2
  6. data/Gemfile +4 -4
  7. data/Gemfile.lock +38 -38
  8. data/LICENSE +22 -22
  9. data/README.md +143 -143
  10. data/Rakefile +2 -2
  11. data/bin/multi +10 -10
  12. data/docs/bug-repros/91565510-repro.sh +20 -20
  13. data/docs/git-multirepo-node-dependency-depth-algorithm.pdf +0 -0
  14. data/docs/graphs/dependencies-on-multiple-levels.graffle +0 -0
  15. data/docs/graphs/dependencies-on-one-level.graffle +0 -0
  16. data/git-multirepo.gemspec +29 -29
  17. data/lib/commands.rb +13 -12
  18. data/lib/git-multirepo.rb +1 -1
  19. data/lib/info.rb +4 -4
  20. data/lib/multirepo/commands/add-command.rb +53 -51
  21. data/lib/multirepo/commands/branch-command.rb +65 -60
  22. data/lib/multirepo/commands/checkout-command.rb +119 -140
  23. data/lib/multirepo/commands/clean-command.rb +31 -31
  24. data/lib/multirepo/commands/clone-command.rb +70 -70
  25. data/lib/multirepo/commands/command.rb +71 -71
  26. data/lib/multirepo/commands/fetch-command.rb +30 -30
  27. data/lib/multirepo/commands/init-command.rb +119 -119
  28. data/lib/multirepo/commands/install-command.rb +103 -103
  29. data/lib/multirepo/commands/merge-command.rb +126 -0
  30. data/lib/multirepo/commands/open-command.rb +26 -26
  31. data/lib/multirepo/commands/remove-command.rb +50 -49
  32. data/lib/multirepo/commands/uninit-command.rb +20 -20
  33. data/lib/multirepo/commands/update-command.rb +59 -59
  34. data/lib/multirepo/config.rb +15 -15
  35. data/lib/multirepo/files/config-entry.rb +34 -34
  36. data/lib/multirepo/files/config-file.rb +45 -34
  37. data/lib/multirepo/files/lock-entry.rb +24 -25
  38. data/lib/multirepo/files/lock-file.rb +39 -28
  39. data/lib/multirepo/files/meta-file.rb +41 -33
  40. data/lib/multirepo/files/tracking-file.rb +8 -8
  41. data/lib/multirepo/files/tracking-files.rb +41 -43
  42. data/lib/multirepo/git/branch.rb +27 -27
  43. data/lib/multirepo/git/change.rb +10 -10
  44. data/lib/multirepo/git/commit.rb +17 -17
  45. data/lib/multirepo/git/git.rb +39 -39
  46. data/lib/multirepo/git/remote.rb +16 -16
  47. data/lib/multirepo/git/repo.rb +77 -77
  48. data/lib/multirepo/hooks/post-commit-hook.rb +22 -22
  49. data/lib/multirepo/hooks/pre-commit-hook.rb +29 -29
  50. data/lib/multirepo/logic/node.rb +41 -0
  51. data/lib/multirepo/logic/performer.rb +59 -0
  52. data/lib/multirepo/logic/revision-selector.rb +27 -0
  53. data/lib/multirepo/multirepo-exception.rb +5 -5
  54. data/lib/multirepo/utility/console.rb +51 -51
  55. data/lib/multirepo/utility/runner.rb +34 -34
  56. data/lib/multirepo/utility/utils.rb +65 -66
  57. data/resources/.gitconfig +2 -2
  58. data/resources/post-commit +5 -5
  59. data/resources/pre-commit +5 -5
  60. data/spec/integration/init_spec.rb +18 -18
  61. data/spec/spec_helper.rb +89 -89
  62. metadata +10 -3
@@ -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
- super
10
- ensure_in_work_tree
11
-
12
- FileUtils.rm_f(".multirepo")
13
- TrackingFiles.delete
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
+ super
10
+ ensure_in_work_tree
11
+
12
+ FileUtils.rm_f(".multirepo")
13
+ TrackingFiles.delete
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,60 +1,60 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/files/tracking-files"
3
-
4
- module MultiRepo
5
- class UpdateCommand < Command
6
- self.command = "update"
7
- self.summary = "Force-updates the multirepo tracking files."
8
-
9
- def self.options
10
- [
11
- ['[--force]', 'Update the tracking files even if dependencies contain uncommitted changes.'],
12
- ['[--commit]', 'Commit the tracking files after updating them.']
13
- ].concat(super)
14
- end
15
-
16
- def initialize(argv)
17
- @commit = argv.flag?("commit")
18
- @force = argv.flag?("force")
19
- super
20
- end
21
-
22
- def run
23
- super
24
- ensure_in_work_tree
25
- ensure_multirepo_enabled
26
-
27
- Console.log_step("Updating...")
28
-
29
- dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load_entries)
30
- if dependencies_clean
31
- update_lock_file_step("Updated tracking files")
32
- elsif !dependencies_clean && @force
33
- update_lock_file_step("Force-updated tracking files (ignoring uncommitted changes)")
34
- else
35
- raise MultiRepoException, "Can't update because not all dependencies are clean"
36
- end
37
-
38
- Console.log_step("Done!")
39
- rescue MultiRepoException => e
40
- Console.log_error(e.message)
41
- end
42
-
43
- def update_lock_file_step(log_message)
44
- changed = TrackingFiles.update
45
-
46
- if changed
47
- Console.log_substep("Updated tracking files")
48
- else
49
- Console.log_substep("Tracking files are already up-to-date")
50
- end
51
-
52
- if @commit
53
- committed = TrackingFiles.commit("[multirepo] Updated tracking files manually")
54
- Console.log_substep("Committed tracking files") if committed
55
- elsif changed
56
- Console.log_substep(log_message)
57
- end
58
- end
59
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/files/tracking-files"
3
+
4
+ module MultiRepo
5
+ class UpdateCommand < Command
6
+ self.command = "update"
7
+ self.summary = "Force-updates the multirepo tracking files."
8
+
9
+ def self.options
10
+ [
11
+ ['[--force]', 'Update the tracking files even if dependencies contain uncommitted changes.'],
12
+ ['[--commit]', 'Commit the tracking files after updating them.']
13
+ ].concat(super)
14
+ end
15
+
16
+ def initialize(argv)
17
+ @commit = argv.flag?("commit")
18
+ @force = argv.flag?("force")
19
+ super
20
+ end
21
+
22
+ def run
23
+ super
24
+ ensure_in_work_tree
25
+ ensure_multirepo_enabled
26
+
27
+ Console.log_step("Updating...")
28
+
29
+ dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.new(".").load_entries)
30
+ if dependencies_clean
31
+ update_lock_file_step("Updated tracking files")
32
+ elsif !dependencies_clean && @force
33
+ update_lock_file_step("Force-updated tracking files (ignoring uncommitted changes)")
34
+ else
35
+ raise MultiRepoException, "Can't update because not all dependencies are clean"
36
+ end
37
+
38
+ Console.log_step("Done!")
39
+ rescue MultiRepoException => e
40
+ Console.log_error(e.message)
41
+ end
42
+
43
+ def update_lock_file_step(log_message)
44
+ changed = TrackingFiles.update
45
+
46
+ if changed
47
+ Console.log_substep("Updated tracking files")
48
+ else
49
+ Console.log_substep("Tracking files are already up-to-date")
50
+ end
51
+
52
+ if @commit
53
+ committed = TrackingFiles.commit("[multirepo] Updated tracking files manually")
54
+ Console.log_substep("Committed tracking files") if committed
55
+ elsif changed
56
+ Console.log_substep(log_message)
57
+ end
58
+ end
59
+ end
60
60
  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
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
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,35 +1,46 @@
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
- FILENAME = FILE.to_s
10
-
11
- def self.exists?
12
- FILE.exist?
13
- end
14
-
15
- def self.load_entries
16
- Psych.load(FILE.read)
17
- end
18
-
19
- def self.save_entries(entries)
20
- File.write(FILENAME, Psych.dump(entries))
21
- end
22
-
23
- def self.entry_exists?(entry)
24
- load_entries.any? { |e| e == entry }
25
- end
26
-
27
- def self.add_entry(entry)
28
- save_entries(load_entries.push(entry))
29
- end
30
-
31
- def self.remove_entry(entry)
32
- save_entries(load_entries.delete_if { |e| e == entry })
33
- end
34
- end
1
+ require "fileutils"
2
+ require "pathname"
3
+
4
+ require_relative "config-entry"
5
+
6
+ module MultiRepo
7
+ class ConfigFile
8
+ FILENAME = ".multirepo"
9
+
10
+ def initialize(path)
11
+ @path = path
12
+ end
13
+
14
+ def file
15
+ File.join(@path, FILENAME)
16
+ end
17
+
18
+ def filename
19
+ FILENAME
20
+ end
21
+
22
+ def exists?
23
+ File.exists?(file)
24
+ end
25
+
26
+ def load_entries
27
+ Psych.load(File.read(file))
28
+ end
29
+
30
+ def save_entries(entries)
31
+ File.write(file, Psych.dump(entries))
32
+ end
33
+
34
+ def entry_exists?(entry)
35
+ load_entries.any? { |e| e == entry }
36
+ end
37
+
38
+ def add_entry(entry)
39
+ save_entries(load_entries.push(entry))
40
+ end
41
+
42
+ def remove_entry(entry)
43
+ save_entries(load_entries.delete_if { |e| e == entry })
44
+ end
45
+ end
35
46
  end
@@ -1,26 +1,25 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/git/repo"
3
-
4
- module MultiRepo
5
- class LockEntry
6
- attr_accessor :config_entry
7
- attr_accessor :name
8
- attr_accessor :id
9
- attr_accessor :head
10
- attr_accessor :branch
11
-
12
- def encode_with(coder)
13
- coder["name"] = @name
14
- coder["id"] = @id
15
- coder["head"] = @head
16
- coder["branch"] = @branch
17
- end
18
-
19
- def initialize(config_entry)
20
- @name = config_entry.repo.basename
21
- @id = config_entry.id
22
- @head = config_entry.repo.head_hash
23
- @branch = config_entry.repo.current_branch
24
- end
25
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/git/repo"
3
+
4
+ module MultiRepo
5
+ class LockEntry
6
+ attr_accessor :name
7
+ attr_accessor :id
8
+ attr_accessor :head
9
+ attr_accessor :branch
10
+
11
+ def encode_with(coder)
12
+ coder["name"] = @name
13
+ coder["id"] = @id
14
+ coder["head"] = @head
15
+ coder["branch"] = @branch
16
+ end
17
+
18
+ def initialize(config_entry)
19
+ @name = config_entry.repo.basename
20
+ @id = config_entry.id
21
+ @head = config_entry.repo.head_hash
22
+ @branch = config_entry.repo.current_branch
23
+ end
24
+ end
26
25
  end
@@ -1,29 +1,40 @@
1
- require "pathname"
2
- require "psych"
3
-
4
- require "multirepo/git/git"
5
- require_relative "tracking-file"
6
- require_relative "lock-entry"
7
- require_relative "config-file"
8
-
9
- module MultiRepo
10
- class LockFile < TrackingFile
11
- FILE = Pathname.new(".multirepo.lock")
12
- FILENAME = FILE.to_s
13
-
14
- def self.exists?
15
- FILE.exist?
16
- end
17
-
18
- def self.load_entries
19
- Psych.load(FILE.read)
20
- end
21
-
22
- def self.update
23
- config_entries = ConfigFile.load_entries
24
- lock_entries = config_entries.map { |c| LockEntry.new(c) }
25
- content = Psych.dump(lock_entries)
26
- return update_internal(FILENAME, content)
27
- end
28
- end
1
+ require "pathname"
2
+ require "psych"
3
+
4
+ require "multirepo/git/git"
5
+ require_relative "tracking-file"
6
+ require_relative "lock-entry"
7
+ require_relative "config-file"
8
+
9
+ module MultiRepo
10
+ class LockFile < TrackingFile
11
+ FILENAME = ".multirepo.lock"
12
+
13
+ def initialize(path)
14
+ @path = path
15
+ end
16
+
17
+ def file
18
+ File.join(@path, FILENAME)
19
+ end
20
+
21
+ def filename
22
+ FILENAME
23
+ end
24
+
25
+ def exists?
26
+ File.exists?(file)
27
+ end
28
+
29
+ def load_entries
30
+ Psych.load(File.read(file))
31
+ end
32
+
33
+ def update
34
+ config_entries = ConfigFile.new(@path).load_entries
35
+ lock_entries = config_entries.map { |c| LockEntry.new(c) }
36
+ content = Psych.dump(lock_entries)
37
+ return update_internal(file, content)
38
+ end
39
+ end
29
40
  end