git-multirepo 1.0.0.beta9 → 1.0.0.beta10

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 (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
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 = "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
+ # 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
data/lib/commands.rb CHANGED
@@ -1,12 +1,12 @@
1
- require_relative "multirepo/commands/command"
2
- require_relative "multirepo/commands/add-command"
3
- require_relative "multirepo/commands/branch-command"
4
- require_relative "multirepo/commands/checkout-command"
5
- require_relative "multirepo/commands/edit-command"
6
- require_relative "multirepo/commands/fetch-command"
7
- require_relative "multirepo/commands/init-command"
8
- require_relative "multirepo/commands/install-command"
9
- require_relative "multirepo/commands/open-command"
10
- require_relative "multirepo/commands/remove-command"
11
- require_relative "multirepo/commands/uninit-command"
1
+ require_relative "multirepo/commands/command"
2
+ require_relative "multirepo/commands/add-command"
3
+ require_relative "multirepo/commands/branch-command"
4
+ require_relative "multirepo/commands/checkout-command"
5
+ require_relative "multirepo/commands/edit-command"
6
+ require_relative "multirepo/commands/fetch-command"
7
+ require_relative "multirepo/commands/init-command"
8
+ require_relative "multirepo/commands/install-command"
9
+ require_relative "multirepo/commands/open-command"
10
+ require_relative "multirepo/commands/remove-command"
11
+ require_relative "multirepo/commands/uninit-command"
12
12
  require_relative "multirepo/commands/update-command"
data/lib/info.rb CHANGED
@@ -1,5 +1,5 @@
1
- module MultiRepo
2
- NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta9"
4
- DESCRIPTION = "Track multiple Git repositories side-by-side."
1
+ module MultiRepo
2
+ NAME = "git-multirepo"
3
+ VERSION = "1.0.0.beta10"
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 AddCommand < 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 AddCommand < 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,51 +1,44 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/files/config-file"
3
-
4
- module MultiRepo
5
- class BranchCommand < Command
6
- self.command = "branch"
7
- self.summary = "Create and/or checkout a new branch for all repos."
8
-
9
- def initialize(argv)
10
- @branch_name = argv.shift_argument
11
- super
12
- end
13
-
14
- def validate!
15
- super
16
- help! "You must specify a branch name" unless @branch_name
17
- end
18
-
19
- def run
20
- super
21
- ensure_multirepo_initialized
22
-
23
- Console.log_step("Branching (\"#{@branch_name}\")...")
24
-
25
- main_repo = main_repo = Repo.new(".")
26
- repos = ConfigFile.load.map{ |entry| entry.repo }.push(main_repo)
27
-
28
- unless ensure_working_copies_clean(repos)
29
- raise MultiRepoException, "Can't branch because not all repos are clean"
30
- end
31
-
32
- repos.each do |repo|
33
- branch = repo.branch(@branch_name)
34
- branch.create unless branch.exists?
35
- branch.checkout
36
- end
37
-
38
- Console.log_step("Done!")
39
- rescue MultiRepoException => e
40
- Console.log_error(e.message)
41
- end
42
-
43
- def ensure_working_copies_clean(repos)
44
- repos.all? do |repo|
45
- clean = repo.is_clean?
46
- Console.log_warning("Repo #{entry.path} has uncommitted changes") unless clean
47
- return clean
48
- end
49
- end
50
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/files/config-file"
3
+
4
+ module MultiRepo
5
+ class BranchCommand < Command
6
+ self.command = "branch"
7
+ self.summary = "Create and/or checkout a new branch for all repos."
8
+
9
+ def initialize(argv)
10
+ @branch_name = argv.shift_argument
11
+ @force = argv.flag?("force")
12
+ super
13
+ end
14
+
15
+ def validate!
16
+ super
17
+ help! "You must specify a branch name" unless @branch_name
18
+ end
19
+
20
+ def run
21
+ super
22
+ ensure_multirepo_initialized
23
+
24
+ Console.log_step("Branching and checking out #{@branch_name}...")
25
+
26
+ main_repo = main_repo = Repo.new(".")
27
+ repos = ConfigFile.load.map{ |entry| entry.repo }.push(main_repo)
28
+
29
+ if !Utils.ensure_working_copies_clean(repos) && !@force
30
+ raise MultiRepoException, "Can't branch because not all repos are clean"
31
+ end
32
+
33
+ repos.each do |repo|
34
+ branch = repo.branch(@branch_name)
35
+ branch.create unless branch.exists?
36
+ branch.checkout
37
+ end
38
+
39
+ Console.log_step("Done!")
40
+ rescue MultiRepoException => e
41
+ Console.log_error(e.message)
42
+ end
43
+ end
51
44
  end
@@ -1,67 +1,67 @@
1
- require "multirepo/utility/console"
2
-
3
- module MultiRepo
4
- class CheckoutCommand < 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
- @checkout_exact = argv.flag?("exact")
12
- super
13
- end
14
-
15
- def validate!
16
- super
17
- help! "You must specify a branch or commit id to checkout" unless @ref
18
- help! "You can't provide more than one operation modifier (--latest, --exact, etc.)" if @checkout_latest && @checkout_exact
19
- end
20
-
21
- def run
22
- super
23
- ensure_multirepo_initialized
24
-
25
- main_repo = Repo.new(".")
26
- initial_revision = main_repo.current_branch || main_repo.head_hash
27
-
28
- Console.log_step("Checking out #{@ref} and its dependencies...")
29
-
30
- unless main_repo.is_clean?
31
- raise MultiRepoException, "Can't checkout #{@ref} because the main repo contains uncommitted changes"
32
- end
33
-
34
- unless main_repo.checkout(@ref)
35
- raise MultiRepoException, "Couldn't perform checkout of main repo #{@ref}!"
36
- end
37
-
38
- Console.log_substep("Checked out main repo #{@ref}")
39
-
40
- unless LockFile.exists?
41
- main_repo.checkout(initial_revision)
42
- raise MultiRepoException, "The specified revision was not managed by multirepo. Checkout reverted."
43
- end
44
-
45
- if Utils.warn_of_uncommitted_changes(ConfigFile.load)
46
- main_repo.checkout(initial_revision)
47
- raise MultiRepoException, "'#{e.path}' contains uncommitted changes. Checkout reverted."
48
- end
49
-
50
- config_entries = ConfigFile.load # Load the post-checkout config entries, which might be different than pre-checkout
51
- LockFile.load.each do |lock_entry|
52
- config_entry = config_entries.select{ |config_entry| config_entry.id == lock_entry.id }.first
53
- revision = @checkout_latest ? lock_entry.branch : lock_entry.head
54
- revision = @checkout_exact ? @ref : revision
55
- if config_entry.repo.checkout(revision)
56
- Console.log_substep("Checked out #{lock_entry.name} #{revision}")
57
- else
58
- raise MultiRepoException, "Couldn't check out the appropriate version of dependency #{lock_entry.name}"
59
- end
60
- end
61
-
62
- Console.log_step("Done!")
63
- rescue MultiRepoException => e
64
- Console.log_error(e.message)
65
- end
66
- end
1
+ require "multirepo/utility/console"
2
+
3
+ module MultiRepo
4
+ class CheckoutCommand < 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
+ @checkout_exact = argv.flag?("exact")
12
+ super
13
+ end
14
+
15
+ def validate!
16
+ super
17
+ help! "You must specify a branch or commit id to checkout" unless @ref
18
+ help! "You can't provide more than one operation modifier (--latest, --exact, etc.)" if @checkout_latest && @checkout_exact
19
+ end
20
+
21
+ def run
22
+ super
23
+ ensure_multirepo_initialized
24
+
25
+ main_repo = Repo.new(".")
26
+ initial_revision = main_repo.current_branch || main_repo.head_hash
27
+
28
+ Console.log_step("Checking out #{@ref} and its dependencies...")
29
+
30
+ unless main_repo.is_clean?
31
+ raise MultiRepoException, "Can't checkout #{@ref} because the main repo contains uncommitted changes"
32
+ end
33
+
34
+ unless main_repo.checkout(@ref)
35
+ raise MultiRepoException, "Couldn't perform checkout of main repo #{@ref}!"
36
+ end
37
+
38
+ Console.log_substep("Checked out main repo #{@ref}")
39
+
40
+ unless LockFile.exists?
41
+ main_repo.checkout(initial_revision)
42
+ raise MultiRepoException, "The specified revision was not managed by multirepo. Checkout reverted."
43
+ end
44
+
45
+ if !Utils.ensure_dependencies_clean(ConfigFile.load)
46
+ main_repo.checkout(initial_revision)
47
+ raise MultiRepoException, "'#{e.path}' contains uncommitted changes. Checkout reverted."
48
+ end
49
+
50
+ config_entries = ConfigFile.load # Load the post-checkout config entries, which might be different than pre-checkout
51
+ LockFile.load.each do |lock_entry|
52
+ config_entry = config_entries.select{ |config_entry| config_entry.id == lock_entry.id }.first
53
+ revision = @checkout_latest ? lock_entry.branch : lock_entry.head
54
+ revision = @checkout_exact ? @ref : revision
55
+ if config_entry.repo.checkout(revision)
56
+ Console.log_substep("Checked out #{lock_entry.name} #{revision}")
57
+ else
58
+ raise MultiRepoException, "Couldn't check out the appropriate version of dependency #{lock_entry.name}"
59
+ end
60
+ end
61
+
62
+ Console.log_step("Done!")
63
+ rescue MultiRepoException => e
64
+ Console.log_error(e.message)
65
+ end
66
+ end
67
67
  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