git-multirepo 1.0.0.beta11 → 1.0.0.beta12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/info.rb +1 -1
- data/lib/multirepo/commands/branch-command.rb +4 -2
- data/lib/multirepo/files/config-file.rb +1 -1
- data/lib/multirepo/files/lock-file.rb +2 -2
- data/lib/multirepo/git/branch.rb +4 -4
- data/lib/multirepo/git/git.rb +11 -11
- data/lib/multirepo/git/remote.rb +1 -1
- data/lib/multirepo/git/repo.rb +6 -6
- data/lib/multirepo/utility/runner.rb +17 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e012e689d7399508df4528f204ae16c4bf9229c
|
4
|
+
data.tar.gz: 8d7e3be3d4584401559ab47683acb8158a388dfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aacad378edef41a3bce28869b916ad88257973948ba65fc1801750af35a8c1128861bc0fafa022dc000b185bb308e4cc993fb5fb487634f6e685b4d555d3a07
|
7
|
+
data.tar.gz: be89879c9d7dc518094b13f56af07584886b4ce7ec4f40ad4b4a51c8ddab70f31a5d15ccd2202150aa10ebd92051a8df19c54e1f733e597d8b4350820ab4ec90
|
data/lib/info.rb
CHANGED
@@ -9,13 +9,15 @@ module MultiRepo
|
|
9
9
|
def self.options
|
10
10
|
[
|
11
11
|
['[branch name]', 'The name of the branch to create and checkout.'],
|
12
|
-
['--force', 'Force creating the branch even if the repos contain uncommmitted changes.']
|
12
|
+
['--force', 'Force creating the branch even if the repos contain uncommmitted changes.'],
|
13
|
+
['--no-track', 'Do not configure as a remote-tracking branch on creation.']
|
13
14
|
].concat(super)
|
14
15
|
end
|
15
16
|
|
16
17
|
def initialize(argv)
|
17
18
|
@branch_name = argv.shift_argument
|
18
19
|
@force = argv.flag?("force")
|
20
|
+
@remote_tracking = !argv.flag?("no-track")
|
19
21
|
super
|
20
22
|
end
|
21
23
|
|
@@ -39,7 +41,7 @@ module MultiRepo
|
|
39
41
|
|
40
42
|
repos.each do |repo|
|
41
43
|
branch = repo.branch(@branch_name)
|
42
|
-
branch.create unless branch.exists?
|
44
|
+
branch.create(@remote_tracking) unless branch.exists?
|
43
45
|
branch.checkout
|
44
46
|
end
|
45
47
|
|
@@ -23,11 +23,11 @@ module MultiRepo
|
|
23
23
|
|
24
24
|
File.write(FILE.to_s, Psych.dump(lock_entries))
|
25
25
|
|
26
|
-
Git.run_in_current_dir("add -A #{FILE.to_s}",
|
26
|
+
Git.run_in_current_dir("add -A #{FILE.to_s}", Runner::Verbosity::OUTPUT_ON_ERROR)
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.commit
|
30
|
-
Git.run_in_current_dir("commit -m \"Updated multirepo lock file with the latest version of all dependencies\" -o -- #{FILE.to_s}",
|
30
|
+
Git.run_in_current_dir("commit -m \"Updated multirepo lock file with the latest version of all dependencies\" -o -- #{FILE.to_s}", Runner::Verbosity::OUTPUT_ON_ERROR)
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.validate_components(line, components)
|
data/lib/multirepo/git/branch.rb
CHANGED
@@ -10,18 +10,18 @@ module MultiRepo
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def exists?
|
13
|
-
lines = Git.run_in_working_dir(@repo.path, "branch",
|
13
|
+
lines = Git.run_in_working_dir(@repo.path, "branch", Runner::Verbosity::NEVER_OUTPUT).split("\n")
|
14
14
|
branch_names = lines.map { |line| line.tr("* ", "")}
|
15
15
|
branch_names.include?(@name)
|
16
16
|
end
|
17
17
|
|
18
18
|
def create(remote_tracking = false)
|
19
|
-
Git.run_in_working_dir(@repo.path, "branch #{@name}",
|
20
|
-
Git.run_in_working_dir(@repo.path, "push -u origin #{name}",
|
19
|
+
Git.run_in_working_dir(@repo.path, "branch #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
|
20
|
+
Git.run_in_working_dir(@repo.path, "push -u origin #{name}", Runner::Verbosity::OUTPUT_ON_ERROR) if remote_tracking
|
21
21
|
end
|
22
22
|
|
23
23
|
def checkout
|
24
|
-
Git.run_in_working_dir(@repo.path, "checkout #{@name}",
|
24
|
+
Git.run_in_working_dir(@repo.path, "checkout #{@name}", Runner::Verbosity::OUTPUT_ON_ERROR)
|
25
25
|
Git.last_command_succeeded
|
26
26
|
end
|
27
27
|
end
|
data/lib/multirepo/git/git.rb
CHANGED
@@ -8,12 +8,17 @@ module MultiRepo
|
|
8
8
|
attr_accessor :last_command_succeeded
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.
|
11
|
+
def self.is_inside_git_repo(path)
|
12
|
+
return false unless Dir.exist?("#{path}/.git")
|
13
|
+
return Git.run_in_working_dir(path, "rev-parse --is-inside-work-tree", Runner::Verbosity::NEVER_OUTPUT).strip == "true"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.run_in_current_dir(git_command, verbosity)
|
12
17
|
full_command = "git #{git_command}"
|
13
|
-
run(full_command,
|
18
|
+
run(full_command, verbosity)
|
14
19
|
end
|
15
20
|
|
16
|
-
def self.run_in_working_dir(path, git_command,
|
21
|
+
def self.run_in_working_dir(path, git_command, verbosity)
|
17
22
|
full_command = "git -C \"#{path}\" #{git_command}";
|
18
23
|
|
19
24
|
# True fix for the -C flag issue in pre-commit hook where the status command would
|
@@ -21,19 +26,14 @@ module MultiRepo
|
|
21
26
|
# http://thread.gmane.org/gmane.comp.version-control.git/263319/focus=263323
|
22
27
|
full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'" if Config.instance.running_git_hook
|
23
28
|
|
24
|
-
run(full_command,
|
29
|
+
run(full_command, verbosity)
|
25
30
|
end
|
26
31
|
|
27
|
-
def self.run(full_command,
|
32
|
+
def self.run(full_command, verbosity)
|
28
33
|
Console.log_info(full_command) if Config.instance.verbose
|
29
|
-
result = Runner.run(full_command,
|
34
|
+
result = Runner.run(full_command, verbosity)
|
30
35
|
@last_command_succeeded = Runner.last_command_succeeded
|
31
36
|
return result
|
32
37
|
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
38
|
end
|
39
39
|
end
|
data/lib/multirepo/git/remote.rb
CHANGED
data/lib/multirepo/git/repo.rb
CHANGED
@@ -19,16 +19,16 @@ module MultiRepo
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def current_branch
|
22
|
-
branch = Git.run_in_working_dir(@path, "rev-parse --abbrev-ref HEAD",
|
22
|
+
branch = Git.run_in_working_dir(@path, "rev-parse --abbrev-ref HEAD", Runner::Verbosity::NEVER_OUTPUT).strip
|
23
23
|
branch != "HEAD" ? branch : nil
|
24
24
|
end
|
25
25
|
|
26
26
|
def head_hash
|
27
|
-
Git.run_in_working_dir(@path, "rev-parse HEAD",
|
27
|
+
Git.run_in_working_dir(@path, "rev-parse HEAD", Runner::Verbosity::NEVER_OUTPUT).strip
|
28
28
|
end
|
29
29
|
|
30
30
|
def changes
|
31
|
-
output = Git.run_in_working_dir(@path, "status --porcelain",
|
31
|
+
output = Git.run_in_working_dir(@path, "status --porcelain", Runner::Verbosity::NEVER_OUTPUT)
|
32
32
|
lines = output.split("\n").each{ |f| f.strip }.delete_if{ |f| f == "" }
|
33
33
|
lines.map { |l| Change.new(l) }
|
34
34
|
end
|
@@ -40,17 +40,17 @@ module MultiRepo
|
|
40
40
|
# Operations
|
41
41
|
|
42
42
|
def fetch
|
43
|
-
Git.run_in_working_dir(@path, "fetch --progress",
|
43
|
+
Git.run_in_working_dir(@path, "fetch --progress", Runner::Verbosity::ALWAYS_OUTPUT)
|
44
44
|
Runner.last_command_succeeded
|
45
45
|
end
|
46
46
|
|
47
47
|
def clone(url)
|
48
|
-
Git.run_in_current_dir("clone #{url} #{@path} --progress",
|
48
|
+
Git.run_in_current_dir("clone #{url} #{@path} --progress", Runner::Verbosity::ALWAYS_OUTPUT)
|
49
49
|
Runner.last_command_succeeded
|
50
50
|
end
|
51
51
|
|
52
52
|
def checkout(ref)
|
53
|
-
Git.run_in_working_dir(@path, "checkout #{ref}",
|
53
|
+
Git.run_in_working_dir(@path, "checkout #{ref}", Runner::Verbosity::OUTPUT_ON_ERROR)
|
54
54
|
Runner.last_command_succeeded
|
55
55
|
end
|
56
56
|
|
@@ -1,21 +1,33 @@
|
|
1
1
|
require "open3"
|
2
|
+
require "multirepo/utility/console"
|
2
3
|
|
3
4
|
module MultiRepo
|
4
5
|
class Runner
|
6
|
+
class Verbosity
|
7
|
+
NEVER_OUTPUT = 0
|
8
|
+
ALWAYS_OUTPUT = 1
|
9
|
+
OUTPUT_ON_ERROR = 2
|
10
|
+
end
|
11
|
+
|
5
12
|
class << self
|
6
13
|
attr_accessor :last_command_succeeded
|
7
14
|
end
|
8
15
|
|
9
|
-
def self.run(cmd,
|
10
|
-
|
16
|
+
def self.run(cmd, verbosity)
|
17
|
+
lines = []
|
11
18
|
Open3.popen2e(cmd) do |stdin, stdout_and_stderr, thread|
|
12
19
|
stdout_and_stderr.each do |line|
|
13
|
-
|
14
|
-
|
20
|
+
Console.log_info(line) if verbosity == Verbosity::ALWAYS_OUTPUT || Config.instance.verbose
|
21
|
+
lines << line
|
15
22
|
end
|
16
23
|
@last_command_succeeded = thread.value.success?
|
17
24
|
end
|
18
|
-
|
25
|
+
|
26
|
+
output = lines.join("").rstrip
|
27
|
+
|
28
|
+
Console.log_error(output) if !@last_command_succeeded && verbosity == Verbosity::OUTPUT_ON_ERROR
|
29
|
+
|
30
|
+
return output
|
19
31
|
end
|
20
32
|
end
|
21
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-multirepo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michaël Fortin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|