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
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+
data/bin/multi CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "claide"
4
- require "commands"
5
-
1
+ #!/usr/bin/env ruby
2
+
3
+ require "claide"
4
+ require "commands"
5
+
6
6
  MultiRepo::Command.run(ARGV)
@@ -1,29 +1,29 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'info'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = MultiRepo::NAME
8
- spec.version = MultiRepo::VERSION
9
- spec.authors = ["Michaël Fortin"]
10
- spec.email = ["fortinmike@irradiated.net"]
11
- spec.summary = %q{Track multiple Git repositories side-by-side}
12
- spec.description = MultiRepo::DESCRIPTION
13
- spec.homepage = "http://www.irradiated.net"
14
- spec.license = "MIT"
15
-
16
- spec.required_ruby_version = '~> 2.0'
17
- spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.1.0"
25
-
26
- spec.add_runtime_dependency "claide", "~> 0.8", ">= 0.8.0"
27
- spec.add_runtime_dependency "colored", "~> 1.2"
28
- spec.add_runtime_dependency "os", "~> 0.9.6"
29
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'info'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = MultiRepo::NAME
8
+ spec.version = MultiRepo::VERSION
9
+ spec.authors = ["Michaël Fortin"]
10
+ spec.email = ["fortinmike@irradiated.net"]
11
+ spec.summary = %q{Track multiple Git repositories side-by-side}
12
+ spec.description = MultiRepo::DESCRIPTION
13
+ spec.homepage = "https://github.com/fortinmike/git-multirepo"
14
+ spec.license = "MIT"
15
+
16
+ spec.required_ruby_version = '~> 2.0'
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.1.0"
25
+
26
+ spec.add_runtime_dependency "claide", "~> 0.8", ">= 0.8.0"
27
+ spec.add_runtime_dependency "colored", "~> 1.2"
28
+ spec.add_runtime_dependency "os", "~> 0.9.6"
29
+ end
@@ -1,11 +1,11 @@
1
- require_relative "multirepo/commands/command"
2
- require_relative "multirepo/commands/add"
3
- require_relative "multirepo/commands/checkout"
4
- require_relative "multirepo/commands/edit"
5
- require_relative "multirepo/commands/fetch"
6
- require_relative "multirepo/commands/init"
7
- require_relative "multirepo/commands/install"
8
- require_relative "multirepo/commands/open"
9
- require_relative "multirepo/commands/remove"
10
- require_relative "multirepo/commands/uninit"
1
+ require_relative "multirepo/commands/command"
2
+ require_relative "multirepo/commands/add"
3
+ require_relative "multirepo/commands/checkout"
4
+ require_relative "multirepo/commands/edit"
5
+ require_relative "multirepo/commands/fetch"
6
+ require_relative "multirepo/commands/init"
7
+ require_relative "multirepo/commands/install"
8
+ require_relative "multirepo/commands/open"
9
+ require_relative "multirepo/commands/remove"
10
+ require_relative "multirepo/commands/uninit"
11
11
  require_relative "multirepo/commands/update"
@@ -1,5 +1,5 @@
1
- module MultiRepo
2
- NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta5"
4
- DESCRIPTION = "Track multiple Git repositories side-by-side."
1
+ module MultiRepo
2
+ NAME = "git-multirepo"
3
+ VERSION = "1.0.0.beta6"
4
+ DESCRIPTION = "Track multiple Git repositories side-by-side."
5
5
  end
@@ -1,41 +1,41 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/files/config-file"
3
-
4
- module MultiRepo
5
- class Add < Command
6
- self.command = "add"
7
- self.summary = "Track an additional dependency with multirepo."
8
-
9
- def initialize(argv)
10
- @path = argv.shift_argument
11
- super
12
- end
13
-
14
- def validate!
15
- super
16
- help! "You must specify a repository to add as a dependency" unless @path
17
- end
18
-
19
- def run
20
- super
21
- ensure_multirepo_initialized
22
- ensure_repo_exists
23
-
24
- entry = ConfigEntry.new(Repo.new(@path))
25
- if ConfigFile.entry_exists?(entry)
26
- Console.log_info("There is already an entry for '#{@path}' in the .multirepo file")
27
- else
28
- ConfigFile.add_entry(entry)
29
- ConfigFile.stage
30
- Console.log_step("Added '#{@path}' to the .multirepo file")
31
- end
32
- rescue MultiRepoException => e
33
- Console.log_error(e.message)
34
- end
35
-
36
- def ensure_repo_exists
37
- raise MultiRepoException, "There is no folder at path '#{@path}'" unless Dir.exists?(@path)
38
- raise MultiRepoException, "'#{@path}' is not a repository" unless Repo.new(@path).exists?
39
- end
40
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/files/config-file"
3
+
4
+ module MultiRepo
5
+ class Add < Command
6
+ self.command = "add"
7
+ self.summary = "Track an additional dependency with multirepo."
8
+
9
+ def initialize(argv)
10
+ @path = argv.shift_argument
11
+ super
12
+ end
13
+
14
+ def validate!
15
+ super
16
+ help! "You must specify a repository to add as a dependency" unless @path
17
+ end
18
+
19
+ def run
20
+ super
21
+ ensure_multirepo_initialized
22
+ ensure_repo_exists
23
+
24
+ entry = ConfigEntry.new(Repo.new(@path))
25
+ if ConfigFile.entry_exists?(entry)
26
+ Console.log_info("There is already an entry for '#{@path}' in the .multirepo file")
27
+ else
28
+ ConfigFile.add_entry(entry)
29
+ ConfigFile.stage
30
+ Console.log_step("Added '#{@path}' to the .multirepo file")
31
+ end
32
+ rescue MultiRepoException => e
33
+ Console.log_error(e.message)
34
+ end
35
+
36
+ def ensure_repo_exists
37
+ raise MultiRepoException, "There is no folder at path '#{@path}'" unless Dir.exists?(@path)
38
+ raise MultiRepoException, "'#{@path}' is not a repository" unless Repo.new(@path).exists?
39
+ end
40
+ end
41
41
  end
@@ -1,64 +1,64 @@
1
- require "multirepo/utility/console"
2
-
3
- module MultiRepo
4
- class Checkout < Command
5
- self.command = "checkout"
6
- self.summary = "Checks out the specified commit or branch of the main repo and checks out matching versions of all dependencies."
7
-
8
- def initialize(argv)
9
- @ref = argv.shift_argument
10
- @checkout_latest = argv.flag?("latest")
11
- super
12
- end
13
-
14
- def validate!
15
- super
16
- help! "You must specify a branch or commit id to checkout" unless @ref
17
- end
18
-
19
- def run
20
- super
21
- ensure_multirepo_initialized
22
-
23
- main_repo = Repo.new(".")
24
- initial_revision = main_repo.current_branch || main_repo.head_hash
25
-
26
- Console.log_step("Checking out #{@ref} and its dependencies...")
27
-
28
- unless main_repo.is_clean?
29
- raise MultiRepoException, "Can't checkout #{@ref} because the main repo contains uncommitted changes"
30
- end
31
-
32
- unless main_repo.checkout(@ref)
33
- raise MultiRepoException, "Couldn't perform checkout of main repo #{@ref}!"
34
- end
35
-
36
- Console.log_substep("Checked out main repo #{@ref}")
37
-
38
- unless LockFile.exists?
39
- main_repo.checkout(initial_revision)
40
- raise MultiRepoException, "The specified revision was not managed by multirepo. Checkout reverted."
41
- end
42
-
43
- if Utils.warn_of_uncommitted_changes(ConfigFile.load)
44
- main_repo.checkout(initial_revision)
45
- raise MultiRepoException, "'#{e.path}' contains uncommitted changes. Checkout reverted."
46
- end
47
-
48
- config_entries = ConfigFile.load # Load the post-checkout config entries, which might be different than pre-checkout
49
- LockFile.load.each do |lock_entry|
50
- config_entry = config_entries.select{ |config_entry| config_entry.id == lock_entry.id }.first
51
- revision = @checkout_latest ? lock_entry.branch : lock_entry.head
52
- if config_entry.repo.checkout(revision)
53
- Console.log_substep("Checked out #{lock_entry.name} #{revision}")
54
- else
55
- raise MultiRepoException, "Couldn't check out the appropriate version of dependency #{lock_entry.name}"
56
- end
57
- end
58
-
59
- Console.log_step("Done!")
60
- rescue MultiRepoException => e
61
- Console.log_error(e.message)
62
- end
63
- end
1
+ require "multirepo/utility/console"
2
+
3
+ module MultiRepo
4
+ class Checkout < Command
5
+ self.command = "checkout"
6
+ self.summary = "Checks out the specified commit or branch of the main repo and checks out matching versions of all dependencies."
7
+
8
+ def initialize(argv)
9
+ @ref = argv.shift_argument
10
+ @checkout_latest = argv.flag?("latest")
11
+ super
12
+ end
13
+
14
+ def validate!
15
+ super
16
+ help! "You must specify a branch or commit id to checkout" unless @ref
17
+ end
18
+
19
+ def run
20
+ super
21
+ ensure_multirepo_initialized
22
+
23
+ main_repo = Repo.new(".")
24
+ initial_revision = main_repo.current_branch || main_repo.head_hash
25
+
26
+ Console.log_step("Checking out #{@ref} and its dependencies...")
27
+
28
+ unless main_repo.is_clean?
29
+ raise MultiRepoException, "Can't checkout #{@ref} because the main repo contains uncommitted changes"
30
+ end
31
+
32
+ unless main_repo.checkout(@ref)
33
+ raise MultiRepoException, "Couldn't perform checkout of main repo #{@ref}!"
34
+ end
35
+
36
+ Console.log_substep("Checked out main repo #{@ref}")
37
+
38
+ unless LockFile.exists?
39
+ main_repo.checkout(initial_revision)
40
+ raise MultiRepoException, "The specified revision was not managed by multirepo. Checkout reverted."
41
+ end
42
+
43
+ if Utils.warn_of_uncommitted_changes(ConfigFile.load)
44
+ main_repo.checkout(initial_revision)
45
+ raise MultiRepoException, "'#{e.path}' contains uncommitted changes. Checkout reverted."
46
+ end
47
+
48
+ config_entries = ConfigFile.load # Load the post-checkout config entries, which might be different than pre-checkout
49
+ LockFile.load.each do |lock_entry|
50
+ config_entry = config_entries.select{ |config_entry| config_entry.id == lock_entry.id }.first
51
+ revision = @checkout_latest ? lock_entry.branch : lock_entry.head
52
+ if config_entry.repo.checkout(revision)
53
+ Console.log_substep("Checked out #{lock_entry.name} #{revision}")
54
+ else
55
+ raise MultiRepoException, "Couldn't check out the appropriate version of dependency #{lock_entry.name}"
56
+ end
57
+ end
58
+
59
+ Console.log_step("Done!")
60
+ rescue MultiRepoException => e
61
+ Console.log_error(e.message)
62
+ end
63
+ end
64
64
  end
@@ -1,41 +1,41 @@
1
- require "claide"
2
-
3
- require "info"
4
- require "multirepo/multirepo-exception"
5
- require "multirepo/config"
6
-
7
- module MultiRepo
8
- class Command < CLAide::Command
9
- self.abstract_command = true
10
- self.command = "multi"
11
- self.version = VERSION
12
- self.description = DESCRIPTION
13
-
14
- def initialize(argv)
15
- Config.instance.verbose = argv.flag?("verbose") ? true : false
16
- super
17
- end
18
-
19
- def run
20
- validate_in_work_tree
21
- end
22
-
23
- def validate_in_work_tree
24
- raise MultiRepoException, "Not a git repository" unless Git.is_inside_git_repo(".")
25
- end
26
-
27
- def install_pre_commit_hook
28
- Utils.install_pre_commit_hook
29
- Console.log_substep("Installed pre-commit hook")
30
- end
31
-
32
- def update_lock_file
33
- LockFile.update
34
- Console.log_substep("Updated and staged lock file with current HEAD revisions for all dependencies")
35
- end
36
-
37
- def ensure_multirepo_initialized
38
- raise MultiRepoException, "multirepo is not initialized in this repository." unless ConfigFile.exists?
39
- end
40
- end
1
+ require "claide"
2
+
3
+ require "info"
4
+ require "multirepo/multirepo-exception"
5
+ require "multirepo/config"
6
+
7
+ module MultiRepo
8
+ class Command < CLAide::Command
9
+ self.abstract_command = true
10
+ self.command = "multi"
11
+ self.version = VERSION
12
+ self.description = DESCRIPTION
13
+
14
+ def initialize(argv)
15
+ Config.instance.verbose = argv.flag?("verbose") ? true : false
16
+ super
17
+ end
18
+
19
+ def run
20
+ validate_in_work_tree
21
+ end
22
+
23
+ def validate_in_work_tree
24
+ raise MultiRepoException, "Not a git repository" unless Git.is_inside_git_repo(".")
25
+ end
26
+
27
+ def install_pre_commit_hook
28
+ Utils.install_pre_commit_hook
29
+ Console.log_substep("Installed pre-commit hook")
30
+ end
31
+
32
+ def update_lock_file
33
+ LockFile.update
34
+ Console.log_substep("Updated and staged lock file with current HEAD revisions for all dependencies")
35
+ end
36
+
37
+ def ensure_multirepo_initialized
38
+ raise MultiRepoException, "multirepo is not initialized in this repository." unless ConfigFile.exists?
39
+ end
40
+ end
41
41
  end
@@ -1,22 +1,22 @@
1
- require "os"
2
-
3
- module MultiRepo
4
- class Edit < Command
5
- self.command = "edit"
6
- self.summary = "Opens the .multirepo file in the default text editor."
7
-
8
- def run
9
- super
10
- ensure_multirepo_initialized
11
-
12
- if OS.posix?
13
- editor = `echo ${FCEDIT:-${VISUAL:-${EDITOR:-vi}}}`.strip
14
- system(editor, ".multirepo")
15
- elsif OS.windows?
16
- raise MultiRepoException, "The edit command is not implemented on Window yet."
17
- end
18
- rescue MultiRepoException => e
19
- Console.log_error(e.message)
20
- end
21
- end
1
+ require "os"
2
+
3
+ module MultiRepo
4
+ class Edit < Command
5
+ self.command = "edit"
6
+ self.summary = "Opens the .multirepo file in the default text editor."
7
+
8
+ def run
9
+ super
10
+ ensure_multirepo_initialized
11
+
12
+ if OS.posix?
13
+ editor = `echo ${FCEDIT:-${VISUAL:-${EDITOR:-vi}}}`.strip
14
+ system(editor, ".multirepo")
15
+ elsif OS.windows?
16
+ raise MultiRepoException, "The edit command is not implemented on Window yet."
17
+ end
18
+ rescue MultiRepoException => e
19
+ Console.log_error(e.message)
20
+ end
21
+ end
22
22
  end
@@ -1,24 +1,24 @@
1
- require "multirepo/utility/console"
2
-
3
- module MultiRepo
4
- class Fetch < Command
5
- self.command = "fetch"
6
- self.summary = "Performs a git fetch on all dependencies."
7
-
8
- def run
9
- super
10
- ensure_multirepo_initialized
11
-
12
- Console.log_step("Fetching dependencies...")
13
-
14
- ConfigFile.load.each do |entry|
15
- Console.log_substep("Fetching from #{entry.repo.remote('origin').url}...")
16
- entry.repo.fetch
17
- end
18
-
19
- Console.log_step("Done!")
20
- rescue MultiRepoException => e
21
- Console.log_error(e.message)
22
- end
23
- end
1
+ require "multirepo/utility/console"
2
+
3
+ module MultiRepo
4
+ class Fetch < Command
5
+ self.command = "fetch"
6
+ self.summary = "Performs a git fetch on all dependencies."
7
+
8
+ def run
9
+ super
10
+ ensure_multirepo_initialized
11
+
12
+ Console.log_step("Fetching dependencies...")
13
+
14
+ ConfigFile.load.each do |entry|
15
+ Console.log_substep("Fetching from #{entry.repo.remote('origin').url}...")
16
+ entry.repo.fetch
17
+ end
18
+
19
+ Console.log_step("Done!")
20
+ rescue MultiRepoException => e
21
+ Console.log_error(e.message)
22
+ end
23
+ end
24
24
  end