git-multirepo 1.0.0.beta5 → 1.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
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,54 +1,54 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/utility/utils"
3
- require "multirepo/files/config-file"
4
- require "multirepo/files/lock-file"
5
- require "multirepo/commands/command"
6
-
7
- module MultiRepo
8
- class Init < Command
9
- self.command = "init"
10
- self.summary = "Initialize the current repository as a multirepo project."
11
-
12
- def run
13
- super
14
- Console.log_step("Initializing new multirepo config...")
15
-
16
- if ConfigFile.exists?
17
- return unless Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
18
- end
19
-
20
- sibling_repos = Utils.sibling_repos
21
-
22
- if sibling_repos.any?
23
- entries = []
24
- sibling_repos.each do |repo|
25
- if Console.ask_yes_no("Do you want to add '#{repo.path}' (#{repo.remote('origin').url} #{repo.current_branch}) as a dependency?")
26
- entries.push(ConfigEntry.new(repo))
27
- Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
28
- end
29
- end
30
-
31
- ConfigFile.save(entries)
32
- ConfigFile.stage
33
-
34
- uncommitted = Utils.warn_of_uncommitted_changes(entries)
35
- raise MultiRepoException, "Can't finish initialization!" if uncommitted
36
-
37
- self.update_lock_file
38
- else
39
- Console.log_info("There are no sibling repositories to add")
40
- end
41
-
42
- self.install_pre_commit_hook
43
-
44
- Console.log_step("Done!")
45
- rescue MultiRepoException => e
46
- Console.log_error(e.message)
47
- end
48
-
49
- def check_repo_exists
50
- if !Dir.exists?(@repo.path) then raise MultiRepoException, "There is no folder at path '#{@repo.path}'" end
51
- if !@repo.exists? then raise MultiRepoException, "'#{@repo.path}' is not a repository" end
52
- end
53
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/utility/utils"
3
+ require "multirepo/files/config-file"
4
+ require "multirepo/files/lock-file"
5
+ require "multirepo/commands/command"
6
+
7
+ module MultiRepo
8
+ class Init < Command
9
+ self.command = "init"
10
+ self.summary = "Initialize the current repository as a multirepo project."
11
+
12
+ def run
13
+ super
14
+ Console.log_step("Initializing new multirepo config...")
15
+
16
+ if ConfigFile.exists?
17
+ return unless Console.ask_yes_no(".multirepo file already exists. Reinitialize?")
18
+ end
19
+
20
+ sibling_repos = Utils.sibling_repos
21
+
22
+ if sibling_repos.any?
23
+ entries = []
24
+ sibling_repos.each do |repo|
25
+ if Console.ask_yes_no("Do you want to add '#{repo.path}' (#{repo.remote('origin').url} #{repo.current_branch}) as a dependency?")
26
+ entries.push(ConfigEntry.new(repo))
27
+ Console.log_substep("Added the repository '#{repo.path}' to the .multirepo file")
28
+ end
29
+ end
30
+
31
+ ConfigFile.save(entries)
32
+ ConfigFile.stage
33
+
34
+ uncommitted = Utils.warn_of_uncommitted_changes(entries)
35
+ raise MultiRepoException, "Can't finish initialization!" if uncommitted
36
+
37
+ self.update_lock_file
38
+ else
39
+ Console.log_info("There are no sibling repositories to add")
40
+ end
41
+
42
+ self.install_pre_commit_hook
43
+
44
+ Console.log_step("Done!")
45
+ rescue MultiRepoException => e
46
+ Console.log_error(e.message)
47
+ end
48
+
49
+ def check_repo_exists
50
+ if !Dir.exists?(@repo.path) then raise MultiRepoException, "There is no folder at path '#{@repo.path}'" end
51
+ if !@repo.exists? then raise MultiRepoException, "'#{@repo.path}' is not a repository" end
52
+ end
53
+ end
54
54
  end
@@ -1,65 +1,65 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/utility/utils"
3
- require "multirepo/git/repo"
4
-
5
- module MultiRepo
6
- class Setup < Command
7
- self.command = "install"
8
- self.summary = "Clones and checks out dependencies as defined in the .multirepo file, and installs git-multirepo's local pre-commit hook."
9
-
10
- def run
11
- super
12
- ensure_multirepo_initialized
13
-
14
- Console.log_step("Cloning dependencies and installing hook...")
15
-
16
- config_entries = ConfigFile.load
17
-
18
- Console.log_info("There are #{config_entries.count} dependencies to install");
19
-
20
- config_entries.each { |e| install(e) }
21
-
22
- self.install_pre_commit_hook
23
-
24
- Console.log_step("Done!")
25
- rescue MultiRepoException => e
26
- Console.log_error(e.message)
27
- end
28
-
29
- def install(entry)
30
- if entry.repo.exists?
31
- check_repo_validity(entry)
32
- fetch_repo(entry)
33
- else
34
- clone_repo(entry)
35
- end
36
- checkout_branch(entry)
37
- end
38
-
39
- # Repo operations
40
-
41
- def fetch_repo(entry)
42
- Console.log_substep("Working copy '#{entry.repo.path}' already exists, fetching instead...")
43
- raise MultiRepoException, "Could not fetch from remote #{entry.repo.remote('origin').url}" unless entry.repo.fetch
44
- end
45
-
46
- def clone_repo(entry)
47
- Console.log_substep("Cloning '#{entry.url} to #{entry.repo.path}'")
48
- raise MultiRepoException, "Could not clone remote #{entry.url}" unless entry.repo.clone(entry.url)
49
- end
50
-
51
- def checkout_branch(entry)
52
- branch = entry.repo.branch(entry.branch);
53
- raise MultiRepoException, "Could not checkout branch #{branch.name}" unless branch.checkout
54
- Console.log_substep("Checked out branch #{branch.name} -> origin/#{branch.name}")
55
- end
56
-
57
- # Validation
58
-
59
- def check_repo_validity(entry)
60
- unless entry.repo.remote("origin").url == entry.url
61
- raise MultiRepoException, "'#{entry.path}' origin URL (#{entry.repo.remote('origin').url}) does not match entry (#{entry.url})!"
62
- end
63
- end
64
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/utility/utils"
3
+ require "multirepo/git/repo"
4
+
5
+ module MultiRepo
6
+ class Setup < Command
7
+ self.command = "install"
8
+ self.summary = "Clones and checks out dependencies as defined in the .multirepo file, and installs git-multirepo's local pre-commit hook."
9
+
10
+ def run
11
+ super
12
+ ensure_multirepo_initialized
13
+
14
+ Console.log_step("Cloning dependencies and installing hook...")
15
+
16
+ config_entries = ConfigFile.load
17
+
18
+ Console.log_info("There are #{config_entries.count} dependencies to install");
19
+
20
+ config_entries.each { |e| install(e) }
21
+
22
+ self.install_pre_commit_hook
23
+
24
+ Console.log_step("Done!")
25
+ rescue MultiRepoException => e
26
+ Console.log_error(e.message)
27
+ end
28
+
29
+ def install(entry)
30
+ if entry.repo.exists?
31
+ check_repo_validity(entry)
32
+ fetch_repo(entry)
33
+ else
34
+ clone_repo(entry)
35
+ end
36
+ checkout_branch(entry)
37
+ end
38
+
39
+ # Repo operations
40
+
41
+ def fetch_repo(entry)
42
+ Console.log_substep("Working copy '#{entry.repo.path}' already exists, fetching instead...")
43
+ raise MultiRepoException, "Could not fetch from remote #{entry.repo.remote('origin').url}" unless entry.repo.fetch
44
+ end
45
+
46
+ def clone_repo(entry)
47
+ Console.log_substep("Cloning '#{entry.url} to #{entry.repo.path}'")
48
+ raise MultiRepoException, "Could not clone remote #{entry.url}" unless entry.repo.clone(entry.url)
49
+ end
50
+
51
+ def checkout_branch(entry)
52
+ branch = entry.repo.branch(entry.branch);
53
+ raise MultiRepoException, "Could not checkout branch #{branch.name}" unless branch.checkout
54
+ Console.log_substep("Checked out branch #{branch.name} -> origin/#{branch.name}")
55
+ end
56
+
57
+ # Validation
58
+
59
+ def check_repo_validity(entry)
60
+ unless entry.repo.remote("origin").url == entry.url
61
+ raise MultiRepoException, "'#{entry.path}' origin URL (#{entry.repo.remote('origin').url}) does not match entry (#{entry.url})!"
62
+ end
63
+ end
64
+ end
65
65
  end
@@ -1,26 +1,26 @@
1
- require "os"
2
-
3
- require "multirepo/utility/console"
4
- require "multirepo/utility/utils"
5
-
6
- module MultiRepo
7
- class Open < Command
8
- self.command = "open"
9
- self.summary = "Opens all dependencies in the current OS's file explorer."
10
-
11
- def run
12
- super
13
- ensure_multirepo_initialized
14
-
15
- ConfigFile.load.each do |entry|
16
- if OS.osx?
17
- `open "#{entry.repo.path}"`
18
- elsif OS.windows?
19
- `explorer "#{Utils.convert_to_windows_path(entry.repo.path)}"`
20
- end
21
- end
22
- rescue MultiRepoException => e
23
- Console.log_error(e.message)
24
- end
25
- end
1
+ require "os"
2
+
3
+ require "multirepo/utility/console"
4
+ require "multirepo/utility/utils"
5
+
6
+ module MultiRepo
7
+ class Open < Command
8
+ self.command = "open"
9
+ self.summary = "Opens all dependencies in the current OS's file explorer."
10
+
11
+ def run
12
+ super
13
+ ensure_multirepo_initialized
14
+
15
+ ConfigFile.load.each do |entry|
16
+ if OS.osx?
17
+ `open "#{entry.repo.path}"`
18
+ elsif OS.windows?
19
+ `explorer "#{Utils.convert_to_windows_path(entry.repo.path)}"`
20
+ end
21
+ end
22
+ rescue MultiRepoException => e
23
+ Console.log_error(e.message)
24
+ end
25
+ end
26
26
  end
@@ -1,42 +1,42 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/files/config-file"
3
-
4
- module MultiRepo
5
- class Remove < Command
6
- self.command = "remove"
7
- self.summary = "Removes the specified dependency from multirepo."
8
-
9
- def initialize(argv)
10
- @path = argv.shift_argument
11
- @delete = argv.flag?("delete")
12
- super
13
- end
14
-
15
- def validate!
16
- super
17
- help! "You must specify a dependency repository to remove" unless @path
18
- end
19
-
20
- def run
21
- super
22
- ensure_multirepo_initialized
23
-
24
- repo = Repo.new(@path)
25
- entry = ConfigEntry.new(repo)
26
-
27
- if ConfigFile.entry_exists?(entry)
28
- ConfigFile.remove_entry(entry)
29
- Console.log_step("Removed '#{@path}' from the .multirepo file")
30
-
31
- if @delete
32
- FileUtils.rm_rf(@path)
33
- Console.log_step("Deleted '#{@path}' from disk")
34
- end
35
- else
36
- raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
37
- end
38
- rescue MultiRepoException => e
39
- Console.log_error(e.message)
40
- end
41
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/files/config-file"
3
+
4
+ module MultiRepo
5
+ class Remove < Command
6
+ self.command = "remove"
7
+ self.summary = "Removes the specified dependency from multirepo."
8
+
9
+ def initialize(argv)
10
+ @path = argv.shift_argument
11
+ @delete = argv.flag?("delete")
12
+ super
13
+ end
14
+
15
+ def validate!
16
+ super
17
+ help! "You must specify a dependency repository to remove" unless @path
18
+ end
19
+
20
+ def run
21
+ super
22
+ ensure_multirepo_initialized
23
+
24
+ repo = Repo.new(@path)
25
+ entry = ConfigEntry.new(repo)
26
+
27
+ if ConfigFile.entry_exists?(entry)
28
+ ConfigFile.remove_entry(entry)
29
+ Console.log_step("Removed '#{@path}' from the .multirepo file")
30
+
31
+ if @delete
32
+ FileUtils.rm_rf(@path)
33
+ Console.log_step("Deleted '#{@path}' from disk")
34
+ end
35
+ else
36
+ raise MultiRepoException, "'#{@path}' isn't tracked by multirepo"
37
+ end
38
+ rescue MultiRepoException => e
39
+ Console.log_error(e.message)
40
+ end
41
+ end
42
42
  end
@@ -1,21 +1,21 @@
1
- require "multirepo/utility/console"
2
-
3
- module MultiRepo
4
- class Uninit < Command
5
- self.command = "uninit"
6
- self.summary = "Removes all traces of multirepo in the current multirepo repository."
7
-
8
- def run
9
- super
10
- ensure_multirepo_initialized
11
-
12
- File.delete(".multirepo")
13
- File.delete(".multirepo.lock")
14
- File.delete(".git/hooks/pre-commit")
15
-
16
- Console.log_step("All traces of multirepo have been removed from this repository")
17
- rescue MultiRepoException => e
18
- Console.log_error(e.message)
19
- end
20
- end
1
+ require "multirepo/utility/console"
2
+
3
+ module MultiRepo
4
+ class Uninit < Command
5
+ self.command = "uninit"
6
+ self.summary = "Removes all traces of multirepo in the current multirepo repository."
7
+
8
+ def run
9
+ super
10
+ ensure_multirepo_initialized
11
+
12
+ File.delete(".multirepo")
13
+ File.delete(".multirepo.lock")
14
+ File.delete(".git/hooks/pre-commit")
15
+
16
+ Console.log_step("All traces of multirepo have been removed from this repository")
17
+ rescue MultiRepoException => e
18
+ Console.log_error(e.message)
19
+ end
20
+ end
21
21
  end
@@ -1,24 +1,24 @@
1
- require "multirepo/utility/console"
2
-
3
- module MultiRepo
4
- class Update < Command
5
- self.command = "update"
6
- self.summary = "Force-updates the multirepo lock file."
7
-
8
- def run
9
- super
10
- ensure_multirepo_initialized
11
-
12
- Console.log_step("Updating...")
13
-
14
- LockFile.update
15
- Console.log_substep("Updated lock file")
16
-
17
- self.install_pre_commit_hook
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 Update < Command
5
+ self.command = "update"
6
+ self.summary = "Force-updates the multirepo lock file."
7
+
8
+ def run
9
+ super
10
+ ensure_multirepo_initialized
11
+
12
+ Console.log_step("Updating...")
13
+
14
+ LockFile.update
15
+ Console.log_substep("Updated lock file")
16
+
17
+ self.install_pre_commit_hook
18
+
19
+ Console.log_step("Done!")
20
+ rescue MultiRepoException => e
21
+ Console.log_error(e.message)
22
+ end
23
+ end
24
24
  end