git-multirepo 1.0.0.beta5 → 1.0.0.beta6

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 (42) 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 +135 -133
  8. data/Rakefile +2 -2
  9. data/bin/multi +5 -5
  10. data/git-multirepo.gemspec +29 -29
  11. data/lib/commands.rb +10 -10
  12. data/lib/info.rb +4 -4
  13. data/lib/multirepo/commands/add.rb +40 -40
  14. data/lib/multirepo/commands/checkout.rb +63 -63
  15. data/lib/multirepo/commands/command.rb +40 -40
  16. data/lib/multirepo/commands/edit.rb +21 -21
  17. data/lib/multirepo/commands/fetch.rb +23 -23
  18. data/lib/multirepo/commands/init.rb +53 -53
  19. data/lib/multirepo/commands/install.rb +64 -64
  20. data/lib/multirepo/commands/open.rb +25 -25
  21. data/lib/multirepo/commands/remove.rb +41 -41
  22. data/lib/multirepo/commands/uninit.rb +20 -20
  23. data/lib/multirepo/commands/update.rb +23 -23
  24. data/lib/multirepo/config.rb +12 -12
  25. data/lib/multirepo/files/config-entry.rb +37 -37
  26. data/lib/multirepo/files/config-file.rb +37 -37
  27. data/lib/multirepo/files/lock-entry.rb +25 -25
  28. data/lib/multirepo/files/lock-file.rb +34 -34
  29. data/lib/multirepo/git/branch.rb +16 -16
  30. data/lib/multirepo/git/change.rb +10 -10
  31. data/lib/multirepo/git/git.rb +38 -38
  32. data/lib/multirepo/git/remote.rb +15 -15
  33. data/lib/multirepo/git/repo.rb +66 -66
  34. data/lib/multirepo/hooks/pre-commit-hook.rb +24 -24
  35. data/lib/multirepo/multirepo-exception.rb +5 -5
  36. data/lib/multirepo/utility/console.rb +51 -51
  37. data/lib/multirepo/utility/runner.rb +20 -20
  38. data/lib/multirepo/utility/utils.rb +36 -36
  39. data/resources/pre-commit +5 -5
  40. data/spec/integration/{init-spec.rb → init_spec.rb} +22 -22
  41. data/spec/spec_helper.rb +89 -89
  42. metadata +6 -6
@@ -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,25 @@
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
+ 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
25
25
  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
@@ -1,37 +1,37 @@
1
- require "fileutils"
2
-
3
- module MultiRepo
4
- class Utils
5
- def self.path_for_resource(resource_name)
6
- gem_path = Gem::Specification.find_by_name("git-multirepo").gem_dir
7
- File.join(gem_path, "resources/#{resource_name}")
8
- end
9
-
10
- def self.install_pre_commit_hook
11
- FileUtils.cp(path_for_resource("pre-commit"), ".git/hooks")
12
- end
13
-
14
- def self.sibling_repos
15
- sibling_directories = Dir['../*/']
16
- sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
17
- sibling_repos.delete_if{ |r| Pathname.new(r.path).realpath == Pathname.new(".").realpath }
18
- end
19
-
20
- def self.warn_of_uncommitted_changes(config_entries)
21
- uncommitted = false
22
- config_entries.each do |e|
23
- next unless e.repo.exists?
24
- unless e.repo.is_clean?
25
- Console.log_warning("Dependency '#{e.repo.path}' contains uncommitted changes")
26
- uncommitted = true
27
- end
28
- end
29
- return uncommitted
30
- end
31
-
32
- def self.convert_to_windows_path(unix_path)
33
- components = Pathname.new(unix_path).each_filename.to_a
34
- components.join(File::ALT_SEPARATOR)
35
- end
36
- end
1
+ require "fileutils"
2
+
3
+ module MultiRepo
4
+ class Utils
5
+ def self.path_for_resource(resource_name)
6
+ gem_path = Gem::Specification.find_by_name("git-multirepo").gem_dir
7
+ File.join(gem_path, "resources/#{resource_name}")
8
+ end
9
+
10
+ def self.install_pre_commit_hook
11
+ FileUtils.cp(path_for_resource("pre-commit"), ".git/hooks")
12
+ end
13
+
14
+ def self.sibling_repos
15
+ sibling_directories = Dir['../*/']
16
+ sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
17
+ sibling_repos.delete_if{ |r| Pathname.new(r.path).realpath == Pathname.new(".").realpath }
18
+ end
19
+
20
+ def self.warn_of_uncommitted_changes(config_entries)
21
+ uncommitted = false
22
+ config_entries.each do |e|
23
+ next unless e.repo.exists?
24
+ unless e.repo.is_clean?
25
+ Console.log_warning("Dependency '#{e.repo.path}' contains uncommitted changes")
26
+ uncommitted = true
27
+ end
28
+ end
29
+ return uncommitted
30
+ end
31
+
32
+ def self.convert_to_windows_path(unix_path)
33
+ components = Pathname.new(unix_path).each_filename.to_a
34
+ components.join(File::ALT_SEPARATOR)
35
+ end
36
+ end
37
37
  end
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "rubygems"
4
- require "git-multirepo"
5
-
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "git-multirepo"
5
+
6
6
  MultiRepo::PreCommitHook.run
@@ -1,23 +1,23 @@
1
- require "multirepo/commands/init"
2
-
3
- RSpec.describe("Init") do
4
- it "creates the config file" do
5
- pending
6
- end
7
-
8
- it "adds only specified repos to the config file" do
9
- pending
10
- end
11
-
12
- it "stages the config file" do
13
- pending
14
- end
15
-
16
- it "installs the pre-commit hook" do
17
- pending
18
- end
19
-
20
- it "fails when there are uncommitted changes in dependencies" do
21
- pending
22
- end
1
+ require "multirepo/commands/init"
2
+
3
+ RSpec.describe("Init") do
4
+ it "creates the config file" do
5
+ pending
6
+ end
7
+
8
+ it "adds only specified repos to the config file" do
9
+ pending
10
+ end
11
+
12
+ it "stages the config file" do
13
+ pending
14
+ end
15
+
16
+ it "installs the pre-commit hook" do
17
+ pending
18
+ end
19
+
20
+ it "fails when there are uncommitted changes in dependencies" do
21
+ pending
22
+ end
23
23
  end