git-multirepo 1.0.0.beta9 → 1.0.0.beta10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) 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 +136 -136
  8. data/Rakefile +2 -2
  9. data/bin/multi +5 -5
  10. data/git-multirepo.gemspec +29 -29
  11. data/lib/commands.rb +11 -11
  12. data/lib/info.rb +4 -4
  13. data/lib/multirepo/commands/add-command.rb +40 -40
  14. data/lib/multirepo/commands/branch-command.rb +43 -50
  15. data/lib/multirepo/commands/checkout-command.rb +66 -66
  16. data/lib/multirepo/commands/command.rb +40 -40
  17. data/lib/multirepo/commands/edit-command.rb +21 -21
  18. data/lib/multirepo/commands/fetch-command.rb +23 -23
  19. data/lib/multirepo/commands/init-command.rb +53 -53
  20. data/lib/multirepo/commands/install-command.rb +64 -64
  21. data/lib/multirepo/commands/open-command.rb +25 -25
  22. data/lib/multirepo/commands/remove-command.rb +41 -41
  23. data/lib/multirepo/commands/uninit-command.rb +20 -20
  24. data/lib/multirepo/commands/update-command.rb +43 -33
  25. data/lib/multirepo/config.rb +12 -12
  26. data/lib/multirepo/files/config-entry.rb +37 -37
  27. data/lib/multirepo/files/config-file.rb +37 -37
  28. data/lib/multirepo/files/lock-entry.rb +25 -25
  29. data/lib/multirepo/files/lock-file.rb +38 -38
  30. data/lib/multirepo/git/branch.rb +27 -27
  31. data/lib/multirepo/git/change.rb +10 -10
  32. data/lib/multirepo/git/git.rb +38 -38
  33. data/lib/multirepo/git/remote.rb +15 -15
  34. data/lib/multirepo/git/repo.rb +66 -66
  35. data/lib/multirepo/hooks/pre-commit-hook.rb +23 -24
  36. data/lib/multirepo/multirepo-exception.rb +5 -5
  37. data/lib/multirepo/utility/console.rb +51 -51
  38. data/lib/multirepo/utility/runner.rb +20 -20
  39. data/lib/multirepo/utility/utils.rb +41 -36
  40. data/resources/pre-commit +5 -5
  41. data/spec/integration/init_spec.rb +22 -22
  42. data/spec/spec_helper.rb +89 -89
  43. metadata +23 -23
@@ -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,39 +1,39 @@
1
- require "multirepo/utility/runner"
2
- require "multirepo/git/git"
3
- require "multirepo/config"
4
-
5
- module MultiRepo
6
- class Git
7
- class << self
8
- attr_accessor :last_command_succeeded
9
- end
10
-
11
- def self.run_in_current_dir(git_command, show_output)
12
- full_command = "git #{git_command}"
13
- run(full_command, show_output)
14
- end
15
-
16
- def self.run_in_working_dir(path, git_command, show_output)
17
- full_command = "git -C \"#{path}\" #{git_command}";
18
-
19
- # True fix for the -C flag issue in pre-commit hook where the status command would
20
- # fail to provide correct results if a pathspec was provided when performing a commit.
21
- # http://thread.gmane.org/gmane.comp.version-control.git/263319/focus=263323
22
- full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'" if Config.instance.running_git_hook
23
-
24
- run(full_command, show_output)
25
- end
26
-
27
- def self.run(full_command, show_output)
28
- Console.log_info(full_command) if Config.instance.verbose
29
- result = Runner.run(full_command, show_output)
30
- @last_command_succeeded = Runner.last_command_succeeded
31
- return result
32
- end
33
-
34
- def self.is_inside_git_repo(path)
35
- return false unless Dir.exist?("#{path}/.git")
36
- return Git.run_in_working_dir(path, "rev-parse --is-inside-work-tree", false).strip == "true"
37
- end
38
- end
1
+ require "multirepo/utility/runner"
2
+ require "multirepo/git/git"
3
+ require "multirepo/config"
4
+
5
+ module MultiRepo
6
+ class Git
7
+ class << self
8
+ attr_accessor :last_command_succeeded
9
+ end
10
+
11
+ def self.run_in_current_dir(git_command, show_output)
12
+ full_command = "git #{git_command}"
13
+ run(full_command, show_output)
14
+ end
15
+
16
+ def self.run_in_working_dir(path, git_command, show_output)
17
+ full_command = "git -C \"#{path}\" #{git_command}";
18
+
19
+ # True fix for the -C flag issue in pre-commit hook where the status command would
20
+ # fail to provide correct results if a pathspec was provided when performing a commit.
21
+ # http://thread.gmane.org/gmane.comp.version-control.git/263319/focus=263323
22
+ full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'" if Config.instance.running_git_hook
23
+
24
+ run(full_command, show_output)
25
+ end
26
+
27
+ def self.run(full_command, show_output)
28
+ Console.log_info(full_command) if Config.instance.verbose
29
+ result = Runner.run(full_command, show_output)
30
+ @last_command_succeeded = Runner.last_command_succeeded
31
+ return result
32
+ end
33
+
34
+ def self.is_inside_git_repo(path)
35
+ return false unless Dir.exist?("#{path}/.git")
36
+ return Git.run_in_working_dir(path, "rev-parse --is-inside-work-tree", false).strip == "true"
37
+ end
38
+ end
39
39
  end
@@ -1,16 +1,16 @@
1
- require_relative "git"
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
- Git.run_in_working_dir(@repo.path, "config --get remote.#{@name}.url", false).strip
14
- end
15
- end
1
+ require_relative "git"
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
+ Git.run_in_working_dir(@repo.path, "config --get remote.#{@name}.url", false).strip
14
+ end
15
+ end
16
16
  end
@@ -1,67 +1,67 @@
1
- require_relative "branch"
2
- require_relative "remote"
3
- require_relative "change"
4
-
5
- module MultiRepo
6
- class Repo
7
- attr_accessor :path
8
- attr_accessor :basename
9
-
10
- def initialize(path)
11
- @path = path
12
- @basename = Pathname.new(path).basename.to_s
13
- end
14
-
15
- # Inspection
16
-
17
- def exists?
18
- Git.is_inside_git_repo(@path)
19
- end
20
-
21
- def current_branch
22
- branch = Git.run_in_working_dir(@path, "rev-parse --abbrev-ref HEAD", false).strip
23
- branch != "HEAD" ? branch : nil
24
- end
25
-
26
- def head_hash
27
- Git.run_in_working_dir(@path, "rev-parse HEAD", false).strip
28
- end
29
-
30
- def changes
31
- output = Git.run_in_working_dir(@path, "status --porcelain", false)
32
- lines = output.split("\n").each{ |f| f.strip }.delete_if{ |f| f == "" }
33
- lines.map { |l| Change.new(l) }
34
- end
35
-
36
- def is_clean?
37
- return changes.count == 0
38
- end
39
-
40
- # Operations
41
-
42
- def fetch
43
- Git.run_in_working_dir(@path, "fetch --progress", true)
44
- Runner.last_command_succeeded
45
- end
46
-
47
- def clone(url)
48
- Git.run_in_current_dir("clone #{url} #{@path} --progress", true)
49
- Runner.last_command_succeeded
50
- end
51
-
52
- def checkout(ref)
53
- Git.run_in_working_dir(@path, "checkout #{ref}", false)
54
- Runner.last_command_succeeded
55
- end
56
-
57
- # Remotes and branches
58
-
59
- def branch(name)
60
- Branch.new(self, name)
61
- end
62
-
63
- def remote(name)
64
- Remote.new(self, name)
65
- end
66
- end
1
+ require_relative "branch"
2
+ require_relative "remote"
3
+ require_relative "change"
4
+
5
+ module MultiRepo
6
+ class Repo
7
+ attr_accessor :path
8
+ attr_accessor :basename
9
+
10
+ def initialize(path)
11
+ @path = path
12
+ @basename = Pathname.new(path).basename.to_s
13
+ end
14
+
15
+ # Inspection
16
+
17
+ def exists?
18
+ Git.is_inside_git_repo(@path)
19
+ end
20
+
21
+ def current_branch
22
+ branch = Git.run_in_working_dir(@path, "rev-parse --abbrev-ref HEAD", false).strip
23
+ branch != "HEAD" ? branch : nil
24
+ end
25
+
26
+ def head_hash
27
+ Git.run_in_working_dir(@path, "rev-parse HEAD", false).strip
28
+ end
29
+
30
+ def changes
31
+ output = Git.run_in_working_dir(@path, "status --porcelain", false)
32
+ lines = output.split("\n").each{ |f| f.strip }.delete_if{ |f| f == "" }
33
+ lines.map { |l| Change.new(l) }
34
+ end
35
+
36
+ def is_clean?
37
+ return changes.count == 0
38
+ end
39
+
40
+ # Operations
41
+
42
+ def fetch
43
+ Git.run_in_working_dir(@path, "fetch --progress", true)
44
+ Runner.last_command_succeeded
45
+ end
46
+
47
+ def clone(url)
48
+ Git.run_in_current_dir("clone #{url} #{@path} --progress", true)
49
+ Runner.last_command_succeeded
50
+ end
51
+
52
+ def checkout(ref)
53
+ Git.run_in_working_dir(@path, "checkout #{ref}", false)
54
+ Runner.last_command_succeeded
55
+ end
56
+
57
+ # Remotes and branches
58
+
59
+ def branch(name)
60
+ Branch.new(self, name)
61
+ end
62
+
63
+ def remote(name)
64
+ Remote.new(self, name)
65
+ end
66
+ end
67
67
  end
@@ -1,25 +1,24 @@
1
- require "multirepo/files/config-file"
2
- require "multirepo/files/lock-file"
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
- entries = ConfigFile.load
12
- uncommitted = Utils.warn_of_uncommitted_changes(entries)
13
-
14
- if uncommitted
15
- Console.log_error("You must commit changes to your dependencies before you can commit the main repo")
16
- exit 1
17
- end
18
-
19
- LockFile.update
20
- Console.log_info("Updated and staged lock file with current HEAD revisions for all dependencies")
21
-
22
- exit 0 # Success!
23
- end
24
- end
1
+ require "multirepo/files/config-file"
2
+ require "multirepo/files/lock-file"
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
+ dependencies_clean = Utils.ensure_dependencies_clean(ConfigFile.load)
12
+
13
+ if !dependencies_clean
14
+ Console.log_error("You must commit changes to your dependencies before you can commit the main repo")
15
+ exit 1
16
+ end
17
+
18
+ LockFile.update
19
+ Console.log_info("Updated and staged lock file with current HEAD revisions for all dependencies")
20
+
21
+ exit 0 # Success!
22
+ end
23
+ end
25
24
  end
@@ -1,6 +1,6 @@
1
- require "claide/informative_error"
2
-
3
- module MultiRepo
4
- class MultiRepoException < StandardError
5
- end
1
+ require "claide/informative_error"
2
+
3
+ module MultiRepo
4
+ class MultiRepoException < StandardError
5
+ end
6
6
  end
@@ -1,52 +1,52 @@
1
- require "colored"
2
-
3
- module MultiRepo
4
- class Console
5
- def self.log_step(message)
6
- print_arrow
7
- puts $stdout.isatty ? message.bold.green : message
8
- end
9
-
10
- def self.log_substep(message)
11
- print_arrow
12
- puts $stdout.isatty ? message.blue : message
13
- end
14
-
15
- def self.log_info(message)
16
- print_arrow
17
- puts $stdout.isatty ? message.white : message
18
- end
19
-
20
- def self.log_warning(message)
21
- print_arrow
22
- puts $stdout.isatty ? message.yellow : message
23
- end
24
-
25
- def self.log_error(message)
26
- print_arrow
27
- puts $stdout.isatty ? message.red : message
28
- end
29
-
30
- def self.ask_yes_no(message)
31
- answered = false
32
- while !answered
33
- print_arrow
34
- print message
35
- print " (y/n) "
36
-
37
- case $stdin.gets.strip.downcase
38
- when "y", "yes"
39
- answered = true
40
- return true
41
- when "n", "no"
42
- answered = true
43
- return false
44
- end
45
- end
46
- end
47
-
48
- def self.print_arrow
49
- print $stdout.isatty ? "> ".white : ""
50
- end
51
- end
1
+ require "colored"
2
+
3
+ module MultiRepo
4
+ class Console
5
+ def self.log_step(message)
6
+ print_arrow
7
+ puts $stdout.isatty ? message.bold.green : message
8
+ end
9
+
10
+ def self.log_substep(message)
11
+ print_arrow
12
+ puts $stdout.isatty ? message.blue : message
13
+ end
14
+
15
+ def self.log_info(message)
16
+ print_arrow
17
+ puts $stdout.isatty ? message.white : message
18
+ end
19
+
20
+ def self.log_warning(message)
21
+ print_arrow
22
+ puts $stdout.isatty ? message.yellow : message
23
+ end
24
+
25
+ def self.log_error(message)
26
+ print_arrow
27
+ puts $stdout.isatty ? message.red : message
28
+ end
29
+
30
+ def self.ask_yes_no(message)
31
+ answered = false
32
+ while !answered
33
+ print_arrow
34
+ print message
35
+ print " (y/n) "
36
+
37
+ case $stdin.gets.strip.downcase
38
+ when "y", "yes"
39
+ answered = true
40
+ return true
41
+ when "n", "no"
42
+ answered = true
43
+ return false
44
+ end
45
+ end
46
+ end
47
+
48
+ def self.print_arrow
49
+ print $stdout.isatty ? "> ".white : ""
50
+ end
51
+ end
52
52
  end
@@ -1,21 +1,21 @@
1
- require "open3"
2
-
3
- module MultiRepo
4
- class Runner
5
- class << self
6
- attr_accessor :last_command_succeeded
7
- end
8
-
9
- def self.run(cmd, show_output)
10
- output = []
11
- Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
12
- stdout_and_stderr.each do |line|
13
- puts line if show_output
14
- output << line
15
- end
16
- @last_command_succeeded = thread.value.success?
17
- end
18
- output.join("")
19
- end
20
- end
1
+ require "open3"
2
+
3
+ module MultiRepo
4
+ class Runner
5
+ class << self
6
+ attr_accessor :last_command_succeeded
7
+ end
8
+
9
+ def self.run(cmd, show_output)
10
+ output = []
11
+ Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
12
+ stdout_and_stderr.each do |line|
13
+ puts line if show_output
14
+ output << line
15
+ end
16
+ @last_command_succeeded = thread.value.success?
17
+ end
18
+ output.join("")
19
+ end
20
+ end
21
21
  end