git-multirepo 1.0.0.beta39 → 1.0.0.beta40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) 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 +146 -145
  11. data/Rakefile +2 -2
  12. data/bin/multi +10 -10
  13. data/docs/bug-repros/91565510-repro.sh +20 -20
  14. data/git-multirepo.gemspec +31 -31
  15. data/lib/commands.rb +15 -14
  16. data/lib/git-multirepo.rb +2 -2
  17. data/lib/info.rb +4 -4
  18. data/lib/multirepo/commands/add-command.rb +53 -53
  19. data/lib/multirepo/commands/branch-command.rb +82 -82
  20. data/lib/multirepo/commands/checkout-command.rb +122 -122
  21. data/lib/multirepo/commands/clean-command.rb +31 -31
  22. data/lib/multirepo/commands/clone-command.rb +70 -70
  23. data/lib/multirepo/commands/command.rb +75 -75
  24. data/lib/multirepo/commands/do-command.rb +76 -0
  25. data/lib/multirepo/commands/fetch-command.rb +30 -30
  26. data/lib/multirepo/commands/graph-command.rb +45 -45
  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 +167 -167
  30. data/lib/multirepo/commands/open-command.rb +57 -57
  31. data/lib/multirepo/commands/remove-command.rb +50 -50
  32. data/lib/multirepo/commands/uninit-command.rb +20 -20
  33. data/lib/multirepo/commands/update-command.rb +60 -60
  34. data/lib/multirepo/config.rb +15 -15
  35. data/lib/multirepo/files/config-entry.rb +38 -38
  36. data/lib/multirepo/files/config-file.rb +45 -45
  37. data/lib/multirepo/files/lock-entry.rb +24 -24
  38. data/lib/multirepo/files/lock-file.rb +38 -38
  39. data/lib/multirepo/files/meta-file.rb +40 -40
  40. data/lib/multirepo/files/tracking-file.rb +8 -8
  41. data/lib/multirepo/files/tracking-files.rb +46 -46
  42. data/lib/multirepo/git/branch.rb +30 -30
  43. data/lib/multirepo/git/change.rb +10 -10
  44. data/lib/multirepo/git/commit.rb +17 -17
  45. data/lib/multirepo/git/git-runner.rb +46 -46
  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 +31 -31
  50. data/lib/multirepo/logic/merge-descriptor.rb +12 -12
  51. data/lib/multirepo/logic/node.rb +44 -44
  52. data/lib/multirepo/logic/performer.rb +62 -62
  53. data/lib/multirepo/logic/revision-selector.rb +34 -34
  54. data/lib/multirepo/multirepo-exception.rb +5 -5
  55. data/lib/multirepo/utility/console.rb +51 -51
  56. data/lib/multirepo/utility/runner.rb +34 -34
  57. data/lib/multirepo/utility/utils.rb +81 -81
  58. data/resources/.gitconfig +2 -2
  59. data/resources/post-commit +5 -5
  60. data/resources/pre-commit +5 -5
  61. data/spec/integration/init_spec.rb +18 -18
  62. data/spec/spec_helper.rb +89 -89
  63. metadata +4 -3
@@ -1,11 +1,11 @@
1
- module MultiRepo
2
- class Change
3
- attr_accessor :status
4
- attr_accessor :path
5
-
6
- def initialize(line)
7
- @status = line[0...2].strip
8
- @path = line[3..-1]
9
- end
10
- end
1
+ module MultiRepo
2
+ class Change
3
+ attr_accessor :status
4
+ attr_accessor :path
5
+
6
+ def initialize(line)
7
+ @status = line[0...2].strip
8
+ @path = line[3..-1]
9
+ end
10
+ end
11
11
  end
@@ -1,18 +1,18 @@
1
- require_relative "git-runner"
2
-
3
- module MultiRepo
4
- class Commit
5
- attr_accessor :ref
6
-
7
- def initialize(repo, ref)
8
- @repo = repo
9
- @ref = ref
10
- end
11
-
12
- def is_merge?
13
- lines = GitRunner.run_in_working_dir(@repo.path, "cat-file -p #{@ref}", Runner::Verbosity::OUTPUT_NEVER).split("\n")
14
- parents = lines.grep(/^parent /)
15
- return parents.count > 1
16
- end
17
- end
1
+ require_relative "git-runner"
2
+
3
+ module MultiRepo
4
+ class Commit
5
+ attr_accessor :ref
6
+
7
+ def initialize(repo, ref)
8
+ @repo = repo
9
+ @ref = ref
10
+ end
11
+
12
+ def is_merge?
13
+ lines = GitRunner.run_in_working_dir(@repo.path, "cat-file -p #{@ref}", Runner::Verbosity::OUTPUT_NEVER).split("\n")
14
+ parents = lines.grep(/^parent /)
15
+ return parents.count > 1
16
+ end
17
+ end
18
18
  end
@@ -1,47 +1,47 @@
1
- require "multirepo/utility/runner"
2
- require "multirepo/config"
3
-
4
- module MultiRepo
5
- class GitRunner
6
- class << self
7
- attr_accessor :last_command_succeeded
8
- end
9
-
10
- def self.run_in_current_dir(git_command, verbosity)
11
- full_command = "#{git_executable} #{git_command}"
12
- run(full_command, verbosity)
13
- end
14
-
15
- def self.run_in_working_dir(path, git_command, verbosity)
16
- if path == "."
17
- # It is always better to skip -C when running git commands in the
18
- # current directory (especially in hooks). Doing this prevents
19
- # any future issues because we automatically fallback to non-"-C" for ".".
20
- # Fixes bug: https://www.pivotaltracker.com/story/show/94505654
21
- return run_in_current_dir(git_command, verbosity)
22
- else
23
- full_command = "#{git_executable} -C \"#{path}\" #{git_command}";
24
- end
25
-
26
- # True fix for the -C flag issue in pre-commit hook where the status command would
27
- # fail to provide correct results if a pathspec was provided when performing a commit.
28
- # http://thread.gmane.org/gmane.comp.version-control.git/263319/focus=263323
29
-
30
- if Config.instance.running_git_hook
31
- full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'"
32
- end
33
-
34
- run(full_command, verbosity)
35
- end
36
-
37
- def self.run(full_command, verbosity)
38
- result = Runner.run(full_command, verbosity)
39
- @last_command_succeeded = Runner.last_command_succeeded
40
- return result
41
- end
42
-
43
- def self.git_executable
44
- Config.instance.git_executable || "git"
45
- end
46
- end
1
+ require "multirepo/utility/runner"
2
+ require "multirepo/config"
3
+
4
+ module MultiRepo
5
+ class GitRunner
6
+ class << self
7
+ attr_accessor :last_command_succeeded
8
+ end
9
+
10
+ def self.run_in_current_dir(git_command, verbosity)
11
+ full_command = "#{git_executable} #{git_command}"
12
+ run(full_command, verbosity)
13
+ end
14
+
15
+ def self.run_in_working_dir(path, git_command, verbosity)
16
+ if path == "."
17
+ # It is always better to skip -C when running git commands in the
18
+ # current directory (especially in hooks). Doing this prevents
19
+ # any future issues because we automatically fallback to non-"-C" for ".".
20
+ # Fixes bug: https://www.pivotaltracker.com/story/show/94505654
21
+ return run_in_current_dir(git_command, verbosity)
22
+ else
23
+ full_command = "#{git_executable} -C \"#{path}\" #{git_command}";
24
+ end
25
+
26
+ # True fix for the -C flag issue in pre-commit hook where the status command would
27
+ # fail to provide correct results if a pathspec was provided when performing a commit.
28
+ # http://thread.gmane.org/gmane.comp.version-control.git/263319/focus=263323
29
+
30
+ if Config.instance.running_git_hook
31
+ full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'"
32
+ end
33
+
34
+ run(full_command, verbosity)
35
+ end
36
+
37
+ def self.run(full_command, verbosity)
38
+ result = Runner.run(full_command, verbosity)
39
+ @last_command_succeeded = Runner.last_command_succeeded
40
+ return result
41
+ end
42
+
43
+ def self.git_executable
44
+ Config.instance.git_executable || "git"
45
+ end
46
+ end
47
47
  end
@@ -1,17 +1,17 @@
1
- require_relative "git-runner"
2
-
3
- module MultiRepo
4
- class Remote
5
- attr_accessor :name
6
-
7
- def initialize(repo, name)
8
- @repo = repo
9
- @name = name
10
- end
11
-
12
- def url
13
- output = GitRunner.run_in_working_dir(@repo.path, "config --get remote.#{@name}.url", Runner::Verbosity::OUTPUT_NEVER).strip
14
- return output == "" ? nil : output
15
- end
16
- end
1
+ require_relative "git-runner"
2
+
3
+ module MultiRepo
4
+ class Remote
5
+ attr_accessor :name
6
+
7
+ def initialize(repo, name)
8
+ @repo = repo
9
+ @name = name
10
+ end
11
+
12
+ def url
13
+ output = GitRunner.run_in_working_dir(@repo.path, "config --get remote.#{@name}.url", Runner::Verbosity::OUTPUT_NEVER).strip
14
+ return output == "" ? nil : output
15
+ end
16
+ end
17
17
  end
@@ -1,78 +1,78 @@
1
- require_relative "branch"
2
- require_relative "remote"
3
- require_relative "commit"
4
- require_relative "change"
5
-
6
- module MultiRepo
7
- class Repo
8
- attr_accessor :path
9
- attr_accessor :basename
10
-
11
- def initialize(path)
12
- @path = path
13
- @basename = Pathname.new(path).basename.to_s
14
- end
15
-
16
- # Inspection
17
-
18
- def exists?
19
- return false unless Dir.exist?("#{@path}/.git")
20
- return GitRunner.run_in_working_dir(@path, "rev-parse --is-inside-work-tree", Runner::Verbosity::OUTPUT_NEVER).strip == "true"
21
- end
22
-
23
- def head_born?
24
- result = GitRunner.run_in_working_dir(@path, "rev-parse HEAD --", Runner::Verbosity::OUTPUT_NEVER).strip
25
- return !result.start_with?("fatal: bad revision")
26
- end
27
-
28
- def current_branch
29
- branch = GitRunner.run_in_working_dir(@path, "rev-parse --abbrev-ref HEAD", Runner::Verbosity::OUTPUT_NEVER).strip
30
- branch != "HEAD" ? branch : nil
31
- end
32
-
33
- def head_hash
34
- GitRunner.run_in_working_dir(@path, "rev-parse HEAD", Runner::Verbosity::OUTPUT_NEVER).strip
35
- end
36
-
37
- def changes
38
- output = GitRunner.run_in_working_dir(@path, "status --porcelain", Runner::Verbosity::OUTPUT_NEVER)
39
- lines = output.split("\n").each{ |f| f.strip }.delete_if{ |f| f == "" }
40
- lines.map { |l| Change.new(l) }
41
- end
42
-
43
- def clean?
44
- return changes.count == 0
45
- end
46
-
47
- # Operations
48
-
49
- def fetch
50
- GitRunner.run_in_working_dir(@path, "fetch --prune --progress", Runner::Verbosity::OUTPUT_ALWAYS)
51
- Runner.last_command_succeeded
52
- end
53
-
54
- def clone(url)
55
- GitRunner.run_in_current_dir("clone #{url} #{@path} --progress", Runner::Verbosity::OUTPUT_ALWAYS)
56
- Runner.last_command_succeeded
57
- end
58
-
59
- def checkout(ref)
60
- GitRunner.run_in_working_dir(@path, "checkout #{ref}", Runner::Verbosity::OUTPUT_ON_ERROR)
61
- Runner.last_command_succeeded
62
- end
63
-
64
- # Remotes and branches
65
-
66
- def branch(name)
67
- Branch.new(self, name)
68
- end
69
-
70
- def remote(name)
71
- Remote.new(self, name)
72
- end
73
-
74
- def commit(ref)
75
- Commit.new(self, ref)
76
- end
77
- end
1
+ require_relative "branch"
2
+ require_relative "remote"
3
+ require_relative "commit"
4
+ require_relative "change"
5
+
6
+ module MultiRepo
7
+ class Repo
8
+ attr_accessor :path
9
+ attr_accessor :basename
10
+
11
+ def initialize(path)
12
+ @path = path
13
+ @basename = Pathname.new(path).basename.to_s
14
+ end
15
+
16
+ # Inspection
17
+
18
+ def exists?
19
+ return false unless Dir.exist?("#{@path}/.git")
20
+ return GitRunner.run_in_working_dir(@path, "rev-parse --is-inside-work-tree", Runner::Verbosity::OUTPUT_NEVER).strip == "true"
21
+ end
22
+
23
+ def head_born?
24
+ result = GitRunner.run_in_working_dir(@path, "rev-parse HEAD --", Runner::Verbosity::OUTPUT_NEVER).strip
25
+ return !result.start_with?("fatal: bad revision")
26
+ end
27
+
28
+ def current_branch
29
+ branch = GitRunner.run_in_working_dir(@path, "rev-parse --abbrev-ref HEAD", Runner::Verbosity::OUTPUT_NEVER).strip
30
+ branch != "HEAD" ? branch : nil
31
+ end
32
+
33
+ def head_hash
34
+ GitRunner.run_in_working_dir(@path, "rev-parse HEAD", Runner::Verbosity::OUTPUT_NEVER).strip
35
+ end
36
+
37
+ def changes
38
+ output = GitRunner.run_in_working_dir(@path, "status --porcelain", Runner::Verbosity::OUTPUT_NEVER)
39
+ lines = output.split("\n").each{ |f| f.strip }.delete_if{ |f| f == "" }
40
+ lines.map { |l| Change.new(l) }
41
+ end
42
+
43
+ def clean?
44
+ return changes.count == 0
45
+ end
46
+
47
+ # Operations
48
+
49
+ def fetch
50
+ GitRunner.run_in_working_dir(@path, "fetch --prune --progress", Runner::Verbosity::OUTPUT_ALWAYS)
51
+ Runner.last_command_succeeded
52
+ end
53
+
54
+ def clone(url)
55
+ GitRunner.run_in_current_dir("clone #{url} #{@path} --progress", Runner::Verbosity::OUTPUT_ALWAYS)
56
+ Runner.last_command_succeeded
57
+ end
58
+
59
+ def checkout(ref)
60
+ GitRunner.run_in_working_dir(@path, "checkout #{ref}", Runner::Verbosity::OUTPUT_ON_ERROR)
61
+ Runner.last_command_succeeded
62
+ end
63
+
64
+ # Remotes and branches
65
+
66
+ def branch(name)
67
+ Branch.new(self, name)
68
+ end
69
+
70
+ def remote(name)
71
+ Remote.new(self, name)
72
+ end
73
+
74
+ def commit(ref)
75
+ Commit.new(self, ref)
76
+ end
77
+ end
78
78
  end
@@ -1,23 +1,23 @@
1
- require "multirepo/files/config-file"
2
- require "multirepo/files/tracking-files"
3
- require "multirepo/utility/utils"
4
- require "multirepo/utility/console"
5
-
6
- module MultiRepo
7
- class PostCommitHook
8
- def self.run
9
- Config.instance.running_git_hook = true
10
-
11
- Console.log_step("Performing post-commit operations...")
12
-
13
- # Works around bug #91565510 (https://www.pivotaltracker.com/story/show/91565510)
14
- TrackingFiles.new(".").stage
15
- Console.log_info("Cleaned-up staging area")
16
-
17
- exit 0 # Success!
18
- rescue StandardError => e
19
- Console.log_error("Post-commit hook failed to execute! #{e.message}")
20
- exit 1 # Something went wrong!
21
- end
22
- end
1
+ require "multirepo/files/config-file"
2
+ require "multirepo/files/tracking-files"
3
+ require "multirepo/utility/utils"
4
+ require "multirepo/utility/console"
5
+
6
+ module MultiRepo
7
+ class PostCommitHook
8
+ def self.run
9
+ Config.instance.running_git_hook = true
10
+
11
+ Console.log_step("Performing post-commit operations...")
12
+
13
+ # Works around bug #91565510 (https://www.pivotaltracker.com/story/show/91565510)
14
+ TrackingFiles.new(".").stage
15
+ Console.log_info("Cleaned-up staging area")
16
+
17
+ exit 0 # Success!
18
+ rescue StandardError => e
19
+ Console.log_error("Post-commit hook failed to execute! #{e.message}")
20
+ exit 1 # Something went wrong!
21
+ end
22
+ end
23
23
  end
@@ -1,32 +1,32 @@
1
- require "multirepo/files/config-file"
2
- require "multirepo/files/tracking-files"
3
- require "multirepo/utility/utils"
4
- require "multirepo/utility/console"
5
-
6
- module MultiRepo
7
- class PreCommitHook
8
- def self.run
9
- Config.instance.running_git_hook = true
10
-
11
- Console.log_step("Performing pre-commit operations...")
12
-
13
- dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.new(".").load_entries)
14
-
15
- if !dependencies_clean
16
- Console.log_error("You must commit changes to your dependencies before you can commit this repo")
17
- exit 1
18
- end
19
-
20
- tracking_files = TrackingFiles.new(".")
21
- tracking_files.update
22
- tracking_files.stage
23
-
24
- Console.log_info("Updated and staged tracking files")
25
-
26
- exit 0 # Success!
27
- rescue StandardError => e
28
- Console.log_error("Pre-commit hook failed to execute! #{e.message}")
29
- exit 1 # Something went wrong!
30
- end
31
- end
1
+ require "multirepo/files/config-file"
2
+ require "multirepo/files/tracking-files"
3
+ require "multirepo/utility/utils"
4
+ require "multirepo/utility/console"
5
+
6
+ module MultiRepo
7
+ class PreCommitHook
8
+ def self.run
9
+ Config.instance.running_git_hook = true
10
+
11
+ Console.log_step("Performing pre-commit operations...")
12
+
13
+ dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.new(".").load_entries)
14
+
15
+ if !dependencies_clean
16
+ Console.log_error("You must commit changes to your dependencies before you can commit this repo")
17
+ exit 1
18
+ end
19
+
20
+ tracking_files = TrackingFiles.new(".")
21
+ tracking_files.update
22
+ tracking_files.stage
23
+
24
+ Console.log_info("Updated and staged tracking files")
25
+
26
+ exit 0 # Success!
27
+ rescue StandardError => e
28
+ Console.log_error("Pre-commit hook failed to execute! #{e.message}")
29
+ exit 1 # Something went wrong!
30
+ end
31
+ end
32
32
  end