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,13 +1,13 @@
1
- require "singleton"
2
-
3
- module MultiRepo
4
- class Config
5
- include Singleton
6
-
7
- attr_accessor :verbose
8
- @verbose = false
9
-
10
- attr_accessor :running_git_hook
11
- @running_git_hook = false
12
- end
1
+ require "singleton"
2
+
3
+ module MultiRepo
4
+ class Config
5
+ include Singleton
6
+
7
+ attr_accessor :verbose
8
+ @verbose = false
9
+
10
+ attr_accessor :running_git_hook
11
+ @running_git_hook = false
12
+ end
13
13
  end
@@ -1,38 +1,38 @@
1
- require "securerandom"
2
-
3
- require "multirepo/utility/console"
4
- require "multirepo/git/repo"
5
-
6
- module MultiRepo
7
- class ConfigEntry
8
- attr_accessor :id
9
- attr_accessor :path
10
- attr_accessor :url
11
- attr_accessor :branch
12
- attr_accessor :repo
13
-
14
- def encode_with(coder)
15
- coder["id"] = @id
16
- coder["path"] = @path
17
- coder["url"] = @url
18
- coder["branch"] = @branch
19
- end
20
-
21
- def ==(entry)
22
- entry_path = Pathname.new(entry.path)
23
- self_path = Pathname.new(self.path)
24
- entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
25
- end
26
-
27
- def initialize(repo)
28
- @id = SecureRandom.uuid
29
- @path = repo.path
30
- @url = repo.exists? ? repo.remote('origin').url : nil
31
- @branch = repo.exists? ? repo.current_branch : nil
32
- end
33
-
34
- def repo
35
- Repo.new(path)
36
- end
37
- end
1
+ require "securerandom"
2
+
3
+ require "multirepo/utility/console"
4
+ require "multirepo/git/repo"
5
+
6
+ module MultiRepo
7
+ class ConfigEntry
8
+ attr_accessor :id
9
+ attr_accessor :path
10
+ attr_accessor :url
11
+ attr_accessor :branch
12
+ attr_accessor :repo
13
+
14
+ def encode_with(coder)
15
+ coder["id"] = @id
16
+ coder["path"] = @path
17
+ coder["url"] = @url
18
+ coder["branch"] = @branch
19
+ end
20
+
21
+ def ==(entry)
22
+ entry_path = Pathname.new(entry.path)
23
+ self_path = Pathname.new(self.path)
24
+ entry_path.exist? && self_path.exist? && entry_path.realpath == self_path.realpath
25
+ end
26
+
27
+ def initialize(repo)
28
+ @id = SecureRandom.uuid
29
+ @path = repo.path
30
+ @url = repo.exists? ? repo.remote('origin').url : nil
31
+ @branch = repo.exists? ? repo.current_branch : nil
32
+ end
33
+
34
+ def repo
35
+ Repo.new(path)
36
+ end
37
+ end
38
38
  end
@@ -1,38 +1,38 @@
1
- require "fileutils"
2
- require "pathname"
3
-
4
- require_relative "config-entry"
5
-
6
- module MultiRepo
7
- class ConfigFile
8
- FILE = Pathname.new(".multirepo")
9
-
10
- def self.exists?
11
- FILE.exist?
12
- end
13
-
14
- def self.load
15
- Psych.load(FILE.read)
16
- end
17
-
18
- def self.save(entries)
19
- File.write(FILE.to_s, Psych.dump(entries))
20
- end
21
-
22
- def self.entry_exists?(entry)
23
- load.any? { |e| e == entry }
24
- end
25
-
26
- def self.add_entry(entry)
27
- save(load.push(entry))
28
- end
29
-
30
- def self.remove_entry(entry)
31
- save(load.delete_if { |e| e == entry })
32
- end
33
-
34
- def self.stage
35
- Git.run_in_current_dir("add -A -f #{FILE.to_s}", false)
36
- end
37
- end
1
+ require "fileutils"
2
+ require "pathname"
3
+
4
+ require_relative "config-entry"
5
+
6
+ module MultiRepo
7
+ class ConfigFile
8
+ FILE = Pathname.new(".multirepo")
9
+
10
+ def self.exists?
11
+ FILE.exist?
12
+ end
13
+
14
+ def self.load
15
+ Psych.load(FILE.read)
16
+ end
17
+
18
+ def self.save(entries)
19
+ File.write(FILE.to_s, Psych.dump(entries))
20
+ end
21
+
22
+ def self.entry_exists?(entry)
23
+ load.any? { |e| e == entry }
24
+ end
25
+
26
+ def self.add_entry(entry)
27
+ save(load.push(entry))
28
+ end
29
+
30
+ def self.remove_entry(entry)
31
+ save(load.delete_if { |e| e == entry })
32
+ end
33
+
34
+ def self.stage
35
+ Git.run_in_current_dir("add -A -f #{FILE.to_s}", false)
36
+ end
37
+ end
38
38
  end
@@ -1,26 +1,26 @@
1
- require "multirepo/utility/console"
2
- require "multirepo/git/repo"
3
-
4
- module MultiRepo
5
- class LockEntry
6
- attr_accessor :config_entry
7
- attr_accessor :name
8
- attr_accessor :id
9
- attr_accessor :head
10
- attr_accessor :branch
11
-
12
- def encode_with(coder)
13
- coder["name"] = @name
14
- coder["id"] = @id
15
- coder["head"] = @head
16
- coder["branch"] = @branch
17
- end
18
-
19
- def initialize(config_entry)
20
- @name = config_entry.repo.basename
21
- @id = config_entry.id
22
- @head = config_entry.repo.head_hash
23
- @branch = config_entry.repo.current_branch
24
- end
25
- end
1
+ require "multirepo/utility/console"
2
+ require "multirepo/git/repo"
3
+
4
+ module MultiRepo
5
+ class LockEntry
6
+ attr_accessor :config_entry
7
+ attr_accessor :name
8
+ attr_accessor :id
9
+ attr_accessor :head
10
+ attr_accessor :branch
11
+
12
+ def encode_with(coder)
13
+ coder["name"] = @name
14
+ coder["id"] = @id
15
+ coder["head"] = @head
16
+ coder["branch"] = @branch
17
+ end
18
+
19
+ def initialize(config_entry)
20
+ @name = config_entry.repo.basename
21
+ @id = config_entry.id
22
+ @head = config_entry.repo.head_hash
23
+ @branch = config_entry.repo.current_branch
24
+ end
25
+ end
26
26
  end
@@ -1,35 +1,35 @@
1
- require "pathname"
2
- require "psych"
3
-
4
- require "multirepo/git/git"
5
- require_relative "lock-entry"
6
- require_relative "config-file"
7
-
8
- module MultiRepo
9
- class LockFile
10
- FILE = Pathname.new(".multirepo.lock")
11
-
12
- def self.exists?
13
- FILE.exist?
14
- end
15
-
16
- def self.load
17
- Psych.load(FILE.read)
18
- end
19
-
20
- def self.update
21
- config_entries = ConfigFile.load
22
- lock_entries = config_entries.map { |c| LockEntry.new(c) }
23
-
24
- File.write(FILE.to_s, Psych.dump(lock_entries))
25
-
26
- Git.run_in_current_dir("add -A -f #{FILE.to_s}", false)
27
- end
28
-
29
- def self.validate_components(line, components)
30
- unless components.count == 2
31
- raise MultiRepoException, "Wrong entry format in .multirepo.lock file: #{line}"
32
- end
33
- end
34
- end
1
+ require "pathname"
2
+ require "psych"
3
+
4
+ require "multirepo/git/git"
5
+ require_relative "lock-entry"
6
+ require_relative "config-file"
7
+
8
+ module MultiRepo
9
+ class LockFile
10
+ FILE = Pathname.new(".multirepo.lock")
11
+
12
+ def self.exists?
13
+ FILE.exist?
14
+ end
15
+
16
+ def self.load
17
+ Psych.load(FILE.read)
18
+ end
19
+
20
+ def self.update
21
+ config_entries = ConfigFile.load
22
+ lock_entries = config_entries.map { |c| LockEntry.new(c) }
23
+
24
+ File.write(FILE.to_s, Psych.dump(lock_entries))
25
+
26
+ Git.run_in_current_dir("add -A #{FILE.to_s}", false)
27
+ end
28
+
29
+ def self.validate_components(line, components)
30
+ unless components.count == 2
31
+ raise MultiRepoException, "Wrong entry format in .multirepo.lock file: #{line}"
32
+ end
33
+ end
34
+ end
35
35
  end
@@ -1,17 +1,17 @@
1
- require_relative "git"
2
-
3
- module MultiRepo
4
- class Branch
5
- attr_accessor :name
6
-
7
- def initialize(repo, name)
8
- @repo = repo
9
- @name = name
10
- end
11
-
12
- def checkout
13
- Git.run_in_working_dir(@repo.path, "checkout #{@name}", false)
14
- Git.last_command_succeeded
15
- end
16
- end
1
+ require_relative "git"
2
+
3
+ module MultiRepo
4
+ class Branch
5
+ attr_accessor :name
6
+
7
+ def initialize(repo, name)
8
+ @repo = repo
9
+ @name = name
10
+ end
11
+
12
+ def checkout
13
+ Git.run_in_working_dir(@repo.path, "checkout #{@name}", false)
14
+ Git.last_command_succeeded
15
+ end
16
+ end
17
17
  end
@@ -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