git-multirepo 1.0.0.beta11 → 1.0.0.beta12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a516af9dddd49b976920b98a8a4445570950c3dd
4
- data.tar.gz: 5208a8d30f9300e81e1fa617642bece5c8481434
3
+ metadata.gz: 8e012e689d7399508df4528f204ae16c4bf9229c
4
+ data.tar.gz: 8d7e3be3d4584401559ab47683acb8158a388dfb
5
5
  SHA512:
6
- metadata.gz: 69fbd3cb2f3c35863bde7e49890c8e9956435ef6b1dcb0c766c51b84f72499ecbd1aa3c9eb7744494a0a874e5d71a25e40583274e80f021a0a7dace247a126e5
7
- data.tar.gz: c7d216c8bb43c02fcd46665506a6a42b148e70c0bed16e67b4cb1bf7baeaa4863acacaca957bc2259ef2eb11c56ebd5829e8eca51128ca27ad2fd854951f7c2c
6
+ metadata.gz: 2aacad378edef41a3bce28869b916ad88257973948ba65fc1801750af35a8c1128861bc0fafa022dc000b185bb308e4cc993fb5fb487634f6e685b4d555d3a07
7
+ data.tar.gz: be89879c9d7dc518094b13f56af07584886b4ce7ec4f40ad4b4a51c8ddab70f31a5d15ccd2202150aa10ebd92051a8df19c54e1f733e597d8b4350820ab4ec90
data/lib/info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module MultiRepo
2
2
  NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta11"
3
+ VERSION = "1.0.0.beta12"
4
4
  DESCRIPTION = "Track multiple Git repositories side-by-side."
5
5
  end
@@ -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
 
@@ -32,7 +32,7 @@ module MultiRepo
32
32
  end
33
33
 
34
34
  def self.stage
35
- Git.run_in_current_dir("add -A -f #{FILE.to_s}", false)
35
+ Git.run_in_current_dir("add -A -f #{FILE.to_s}", Runner::Verbosity::NEVER_OUTPUT)
36
36
  end
37
37
  end
38
38
  end
@@ -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}", false)
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}", false)
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)
@@ -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", false).split("\n")
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}", false)
20
- Git.run_in_working_dir(@repo.path, "push -u origin #{name}", false) if remote_tracking
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}", false)
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
@@ -8,12 +8,17 @@ module MultiRepo
8
8
  attr_accessor :last_command_succeeded
9
9
  end
10
10
 
11
- def self.run_in_current_dir(git_command, show_output)
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, show_output)
18
+ run(full_command, verbosity)
14
19
  end
15
20
 
16
- def self.run_in_working_dir(path, git_command, show_output)
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, show_output)
29
+ run(full_command, verbosity)
25
30
  end
26
31
 
27
- def self.run(full_command, show_output)
32
+ def self.run(full_command, verbosity)
28
33
  Console.log_info(full_command) if Config.instance.verbose
29
- result = Runner.run(full_command, show_output)
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
@@ -10,7 +10,7 @@ module MultiRepo
10
10
  end
11
11
 
12
12
  def url
13
- Git.run_in_working_dir(@repo.path, "config --get remote.#{@name}.url", false).strip
13
+ Git.run_in_working_dir(@repo.path, "config --get remote.#{@name}.url", Runner::Verbosity::NEVER_OUTPUT).strip
14
14
  end
15
15
  end
16
16
  end
@@ -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", false).strip
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", false).strip
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", false)
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", true)
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", true)
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}", false)
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, show_output)
10
- output = []
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
- puts line if show_output
14
- output << line
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
- output.join("")
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.beta11
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-22 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler