git-multirepo 1.0.0.beta40 → 1.0.0.beta42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) 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/Gemfile +4 -4
  8. data/Gemfile.lock +42 -42
  9. data/LICENSE +22 -22
  10. data/README.md +143 -146
  11. data/Rakefile +2 -2
  12. data/bin/multi +10 -10
  13. data/docs/bug-repros/91565510-repro.sh +20 -20
  14. data/docs/git-multirepo-cheatsheet.docx +0 -0
  15. data/git-multirepo.gemspec +31 -31
  16. data/lib/commands.rb +13 -15
  17. data/lib/git-multirepo.rb +2 -2
  18. data/lib/info.rb +4 -4
  19. data/lib/multirepo/commands/add-command.rb +50 -53
  20. data/lib/multirepo/commands/branch-command.rb +81 -82
  21. data/lib/multirepo/commands/checkout-command.rb +119 -122
  22. data/lib/multirepo/commands/clone-command.rb +67 -70
  23. data/lib/multirepo/commands/command.rb +89 -75
  24. data/lib/multirepo/commands/do-command.rb +100 -75
  25. data/lib/multirepo/commands/graph-command.rb +42 -45
  26. data/lib/multirepo/commands/init-command.rb +119 -119
  27. data/lib/multirepo/commands/install-command.rb +106 -103
  28. data/lib/multirepo/commands/merge-command.rb +225 -167
  29. data/lib/multirepo/commands/open-command.rb +55 -57
  30. data/lib/multirepo/commands/remove-command.rb +47 -50
  31. data/lib/multirepo/commands/uninit-command.rb +17 -20
  32. data/lib/multirepo/commands/update-command.rb +55 -60
  33. data/lib/multirepo/config.rb +15 -15
  34. data/lib/multirepo/files/config-entry.rb +38 -38
  35. data/lib/multirepo/files/config-file.rb +45 -45
  36. data/lib/multirepo/files/lock-entry.rb +28 -24
  37. data/lib/multirepo/files/lock-file.rb +55 -38
  38. data/lib/multirepo/files/meta-file.rb +40 -40
  39. data/lib/multirepo/files/tracking-file.rb +8 -8
  40. data/lib/multirepo/files/tracking-files.rb +46 -46
  41. data/lib/multirepo/git/branch.rb +31 -30
  42. data/lib/multirepo/git/change.rb +10 -10
  43. data/lib/multirepo/git/commit.rb +6 -17
  44. data/lib/multirepo/git/git-runner.rb +46 -46
  45. data/lib/multirepo/git/git.rb +10 -0
  46. data/lib/multirepo/git/ref.rb +38 -0
  47. data/lib/multirepo/git/remote.rb +16 -16
  48. data/lib/multirepo/git/repo.rb +122 -77
  49. data/lib/multirepo/hooks/post-commit-hook.rb +22 -22
  50. data/lib/multirepo/hooks/pre-commit-hook.rb +34 -31
  51. data/lib/multirepo/logic/dependency.rb +6 -0
  52. data/lib/multirepo/logic/merge-descriptor.rb +94 -12
  53. data/lib/multirepo/logic/node.rb +71 -44
  54. data/lib/multirepo/logic/performer.rb +56 -62
  55. data/lib/multirepo/logic/revision-selector.rb +34 -34
  56. data/lib/multirepo/multirepo-exception.rb +5 -5
  57. data/lib/multirepo/utility/console.rb +51 -51
  58. data/lib/multirepo/utility/runner.rb +34 -34
  59. data/lib/multirepo/utility/utils.rb +94 -81
  60. data/resources/.gitconfig +2 -2
  61. data/resources/post-commit +5 -5
  62. data/resources/pre-commit +5 -5
  63. data/spec/integration/init_spec.rb +18 -18
  64. data/spec/spec_helper.rb +89 -89
  65. metadata +6 -5
  66. data/lib/multirepo/commands/clean-command.rb +0 -32
  67. data/lib/multirepo/commands/fetch-command.rb +0 -31
@@ -1,46 +1,46 @@
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
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
46
46
  end
@@ -1,25 +1,29 @@
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.name
20
- @id = config_entry.id
21
- @head = config_entry.repo.head_hash
22
- @branch = config_entry.repo.current_branch
23
- end
24
- 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.name
20
+ @id = config_entry.id
21
+
22
+ head = config_entry.repo.head
23
+ @head = head.commit_id
24
+
25
+ current_branch = config_entry.repo.current_branch
26
+ @branch = current_branch ? current_branch.name : nil
27
+ end
28
+ end
25
29
  end
@@ -1,39 +1,56 @@
1
- require "pathname"
2
- require "psych"
3
-
4
- require_relative "tracking-file"
5
- require_relative "lock-entry"
6
- require_relative "config-file"
7
-
8
- module MultiRepo
9
- class LockFile < TrackingFile
10
- FILENAME = ".multirepo.lock"
11
-
12
- def initialize(path)
13
- @path = path
14
- end
15
-
16
- def file
17
- File.join(@path, FILENAME)
18
- end
19
-
20
- def filename
21
- FILENAME
22
- end
23
-
24
- def exists?
25
- File.exists?(file)
26
- end
27
-
28
- def load_entries
29
- Psych.load(File.read(file))
30
- end
31
-
32
- def update
33
- config_entries = ConfigFile.new(@path).load_entries
34
- lock_entries = config_entries.map { |c| LockEntry.new(c) }
35
- content = Psych.dump(lock_entries)
36
- return update_internal(file, content)
37
- end
38
- end
1
+ require "pathname"
2
+ require "psych"
3
+
4
+ require_relative "tracking-file"
5
+ require_relative "lock-entry"
6
+ require_relative "config-file"
7
+
8
+ module MultiRepo
9
+ class LockFile < TrackingFile
10
+ FILENAME = ".multirepo.lock"
11
+
12
+ def initialize(path)
13
+ @path = path
14
+ end
15
+
16
+ def file
17
+ File.join(@path, FILENAME)
18
+ end
19
+
20
+ def filename
21
+ FILENAME
22
+ end
23
+
24
+ def exists?
25
+ File.exists?(file)
26
+ end
27
+
28
+ def load_entries
29
+ Psych.load(File.read(file))
30
+ end
31
+
32
+ def update
33
+ config_entries = ConfigFile.new(@path).load_entries
34
+ lock_entries = config_entries.map { |c| LockEntry.new(c) }
35
+ content = Psych.dump(lock_entries)
36
+ return update_internal(file, content)
37
+ end
38
+
39
+ def validate!
40
+ load_entries.all? { |e| validate_entry! e }
41
+ end
42
+
43
+ def validate_entry!(entry)
44
+ valid = true
45
+
46
+ # head
47
+ valid &= /\b([a-f0-9]{40})\b/ =~ entry.head.to_s
48
+
49
+ # branch
50
+ GitRunner.run_in_working_dir(@path, "check-ref-format --branch #{entry.branch}", Runner::Verbosity::OUTPUT_NEVER)
51
+ valid &= (entry.branch == "" || GitRunner.last_command_succeeded)
52
+
53
+ return valid
54
+ end
55
+ end
39
56
  end
@@ -1,41 +1,41 @@
1
- require "pathname"
2
- require "psych"
3
-
4
- require "info"
5
- require_relative "tracking-file"
6
- require_relative "lock-entry"
7
- require_relative "config-file"
8
-
9
- module MultiRepo
10
- class MetaFile < TrackingFile
11
- FILENAME = ".multirepo.meta"
12
-
13
- attr_accessor :version
14
-
15
- def initialize(path)
16
- @path = path
17
- @version = MultiRepo::VERSION
18
- end
19
-
20
- def file
21
- File.join(@path, FILENAME)
22
- end
23
-
24
- def filename
25
- FILENAME
26
- end
27
-
28
- def encode_with(coder)
29
- coder["version"] = @version
30
- end
31
-
32
- def load
33
- Psych.load(file)
34
- end
35
-
36
- def update
37
- content = Psych.dump(self)
38
- return update_internal(file, content)
39
- end
40
- end
1
+ require "pathname"
2
+ require "psych"
3
+
4
+ require "info"
5
+ require_relative "tracking-file"
6
+ require_relative "lock-entry"
7
+ require_relative "config-file"
8
+
9
+ module MultiRepo
10
+ class MetaFile < TrackingFile
11
+ FILENAME = ".multirepo.meta"
12
+
13
+ attr_accessor :version
14
+
15
+ def initialize(path)
16
+ @path = path
17
+ @version = MultiRepo::VERSION
18
+ end
19
+
20
+ def file
21
+ File.join(@path, FILENAME)
22
+ end
23
+
24
+ def filename
25
+ FILENAME
26
+ end
27
+
28
+ def encode_with(coder)
29
+ coder["version"] = @version
30
+ end
31
+
32
+ def load
33
+ Psych.load(file)
34
+ end
35
+
36
+ def update
37
+ content = Psych.dump(self)
38
+ return update_internal(file, content)
39
+ end
40
+ end
41
41
  end
@@ -1,9 +1,9 @@
1
- module MultiRepo
2
- class TrackingFile
3
- def update_internal(file, new_content)
4
- old_content = File.exists?(file) ? File.read(file) : nil
5
- File.write(file, new_content)
6
- return new_content != old_content
7
- end
8
- end
1
+ module MultiRepo
2
+ class TrackingFile
3
+ def update_internal(file, new_content)
4
+ old_content = File.exists?(file) ? File.read(file) : nil
5
+ File.write(file, new_content)
6
+ return new_content != old_content
7
+ end
8
+ end
9
9
  end
@@ -1,47 +1,47 @@
1
- require "multirepo/git/git-runner"
2
- require_relative "meta-file"
3
- require_relative "lock-file"
4
-
5
- module MultiRepo
6
- class TrackingFiles
7
- attr_accessor :files
8
-
9
- def initialize(path)
10
- @path = path
11
- @files = [MetaFile.new(path), LockFile.new(path)]
12
- end
13
-
14
- def update
15
- updated = false
16
- files.each { |f| updated |= f.update }
17
- return updated
18
- end
19
-
20
- def stage
21
- GitRunner.run_in_working_dir(@path, "add --force -- #{files_pathspec}", Runner::Verbosity::OUTPUT_ON_ERROR)
22
- end
23
-
24
- def commit(message)
25
- stage
26
-
27
- output = GitRunner.run_in_working_dir(@path, "ls-files --modified --others -- #{files_pathspec}", Runner::Verbosity::OUTPUT_NEVER)
28
- files_are_untracked_or_modified = output.strip != ""
29
-
30
- output = GitRunner.run_in_working_dir(@path, "diff --name-only --cached -- #{files_pathspec}", Runner::Verbosity::OUTPUT_NEVER)
31
- files_are_staged = output.strip != ""
32
-
33
- must_commit = files_are_untracked_or_modified || files_are_staged
34
- GitRunner.run_in_working_dir(@path, "commit --no-verify -m \"#{message}\" --only -- #{files_pathspec}", Runner::Verbosity::OUTPUT_ON_ERROR) if must_commit
35
-
36
- return must_commit
37
- end
38
-
39
- def delete
40
- files.each { |f| FileUtils.rm_f(f.file) }
41
- end
42
-
43
- def files_pathspec
44
- files.map{ |f| File.basename(f.file) }.join(" ")
45
- end
46
- end
1
+ require "multirepo/git/git-runner"
2
+ require_relative "meta-file"
3
+ require_relative "lock-file"
4
+
5
+ module MultiRepo
6
+ class TrackingFiles
7
+ attr_accessor :files
8
+
9
+ def initialize(path)
10
+ @path = path
11
+ @files = [MetaFile.new(path), LockFile.new(path)]
12
+ end
13
+
14
+ def update
15
+ updated = false
16
+ files.each { |f| updated |= f.update }
17
+ return updated
18
+ end
19
+
20
+ def stage
21
+ GitRunner.run_in_working_dir(@path, "add --force -- #{files_pathspec}", Runner::Verbosity::OUTPUT_ON_ERROR)
22
+ end
23
+
24
+ def commit(message)
25
+ stage
26
+
27
+ output = GitRunner.run_in_working_dir(@path, "ls-files --modified --others -- #{files_pathspec}", Runner::Verbosity::OUTPUT_NEVER)
28
+ files_are_untracked_or_modified = output.strip != ""
29
+
30
+ output = GitRunner.run_in_working_dir(@path, "diff --name-only --cached -- #{files_pathspec}", Runner::Verbosity::OUTPUT_NEVER)
31
+ files_are_staged = output.strip != ""
32
+
33
+ must_commit = files_are_untracked_or_modified || files_are_staged
34
+ GitRunner.run_in_working_dir(@path, "commit --no-verify -m \"#{message}\" --only -- #{files_pathspec}", Runner::Verbosity::OUTPUT_ON_ERROR) if must_commit
35
+
36
+ return must_commit
37
+ end
38
+
39
+ def delete
40
+ files.each { |f| FileUtils.rm_f(f.file) }
41
+ end
42
+
43
+ def files_pathspec
44
+ files.map{ |f| File.basename(f.file) }.join(" ")
45
+ end
46
+ end
47
47
  end
@@ -1,31 +1,32 @@
1
- require_relative "git-runner"
2
-
3
- module MultiRepo
4
- class Branch
5
- attr_accessor :name
6
-
7
- def initialize(repo, name)
8
- @repo = repo
9
- @name = name
10
- end
11
-
12
- def exists?
13
- lines = GitRunner.run_in_working_dir(@repo.path, "branch", Runner::Verbosity::OUTPUT_NEVER).split("\n")
14
- branch_names = lines.map { |line| line.tr("* ", "")}
15
- branch_names.include?(@name)
16
- end
17
-
18
- def create
19
- GitRunner.run_in_working_dir(@repo.path, "branch #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
20
- end
21
-
22
- def push
23
- GitRunner.run_in_working_dir(@repo.path, "push -u origin #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
24
- end
25
-
26
- def checkout
27
- GitRunner.run_in_working_dir(@repo.path, "checkout #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
28
- GitRunner.last_command_succeeded
29
- end
30
- end
1
+ require_relative "ref"
2
+ require_relative "git-runner"
3
+
4
+ module MultiRepo
5
+ class Branch < Ref
6
+ def exists?
7
+ lines = GitRunner.run_in_working_dir(@repo.path, "branch", Runner::Verbosity::OUTPUT_NEVER).split("\n")
8
+ branch_names = lines.map { |line| line.tr("* ", "")}
9
+ branch_names.include?(@name)
10
+ end
11
+
12
+ def upstream_branch
13
+ output = GitRunner.run_in_working_dir(@repo.path, "config --get branch.#{@name}.merge", Runner::Verbosity::OUTPUT_NEVER)
14
+ output.sub!("refs/heads/", "")
15
+ return nil if output == ""
16
+ Branch.new(@repo, "origin/#{output}")
17
+ end
18
+
19
+ def create
20
+ GitRunner.run_in_working_dir(@repo.path, "branch #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
21
+ end
22
+
23
+ def push
24
+ GitRunner.run_in_working_dir(@repo.path, "push -u origin #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
25
+ end
26
+
27
+ def checkout
28
+ GitRunner.run_in_working_dir(@repo.path, "checkout #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
29
+ GitRunner.last_command_succeeded
30
+ end
31
+ end
31
32
  end