mgit 0.2.1 → 0.2.2
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 +8 -8
- data/lib/mgit.rb +1 -0
- data/lib/mgit/command.rb +6 -14
- data/lib/mgit/commands/clone.rb +0 -1
- data/lib/mgit/commands/fetch.rb +1 -1
- data/lib/mgit/commands/ffmerge.rb +2 -2
- data/lib/mgit/commands/foreach.rb +1 -1
- data/lib/mgit/commands/grep.rb +1 -1
- data/lib/mgit/commands/help.rb +4 -4
- data/lib/mgit/commands/list.rb +3 -5
- data/lib/mgit/commands/log.rb +5 -5
- data/lib/mgit/commands/remove.rb +1 -1
- data/lib/mgit/commands/status.rb +3 -5
- data/lib/mgit/commands/version.rb +1 -1
- data/lib/mgit/output.rb +73 -0
- data/lib/mgit/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjllZmRiNWExNjk4ZmJjZmVkNjI4ZTJhZGRiZThhOWMyYWVjNDEwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzY1NmE3YWEwOWY5NjJiOGI1ZjNmMTczNjJkNTlhMjA1NDhmYmYzZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmEyZWI3M2Y4Njg4NjkwZGU1NWRiZjk0Y2QzOWNiOWRkNjM2YjllNDg4NWVj
|
10
|
+
NmYzYjJkZWVmZjQwNWZiZjE1NDFjYjVlZGU4ZDBlYWQxYmJhMjZmZTE2ZjE4
|
11
|
+
YWQ1ODQxMzAyNzU4ZWY1ZTlhYzg3MWJkZjQ5ZmJmNzVlODFhMmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDUyZGY4N2I5ZGY4NTRkZmFlMmM0YTJhYmU0Y2MzOGQ0MDE5Y2QzMmRhYjE1
|
14
|
+
MzQ5NTkzZGFiMTJmYTExNzBlODI2MmYyMjA5NjAxZTZlM2I1Yzg4NDkxYmJh
|
15
|
+
OTgwYTg4NGZhMzYwM2NjZDEyZGRmMjA4ZWFhYWMzODYwZGQ5ZmM=
|
data/lib/mgit.rb
CHANGED
data/lib/mgit/command.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module MGit
|
2
2
|
class Command
|
3
|
+
include Output
|
4
|
+
|
3
5
|
@@commands = {}
|
4
6
|
@@aliases = {}
|
5
7
|
|
@@ -31,20 +33,10 @@ module MGit
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def usage
|
39
|
-
raise ImplementationError.new("Command #{self.class.name} doesn't implement the usage method.")
|
40
|
-
end
|
41
|
-
|
42
|
-
def help
|
43
|
-
raise ImplementationError.new("Command #{self.class.name} doesn't implement the help method.")
|
44
|
-
end
|
45
|
-
|
46
|
-
def description
|
47
|
-
raise ImplementationError.new("Command #{self.class.name} doesn't implement the description method.")
|
36
|
+
[:arity, :usage, :help, :description].each do |meth|
|
37
|
+
define_method(meth) do
|
38
|
+
raise ImplementationError.new("Command #{self.class.name} doesn't implement the #{meth.to_s} method.")
|
39
|
+
end
|
48
40
|
end
|
49
41
|
|
50
42
|
private
|
data/lib/mgit/commands/clone.rb
CHANGED
data/lib/mgit/commands/fetch.rb
CHANGED
@@ -3,11 +3,11 @@ module MGit
|
|
3
3
|
def execute(args)
|
4
4
|
Registry.chdir_each do |repo|
|
5
5
|
if repo.dirty?
|
6
|
-
|
6
|
+
pwarn "Skipping repository #{repo.name} since it's dirty."
|
7
7
|
next
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
pinfo "Fast-forward merging branches in repository #{repo.name}..."
|
11
11
|
|
12
12
|
cb = repo.current_branch
|
13
13
|
repo.remote_tracking_branches.each do |b, u|
|
@@ -4,7 +4,7 @@ module MGit
|
|
4
4
|
command = args.join(' ')
|
5
5
|
|
6
6
|
Registry.chdir_each do |repo|
|
7
|
-
|
7
|
+
pinfo "Executing command in repository #{repo.name}..."
|
8
8
|
if !system(command) && !ask("Executing command '#{command}' in repository '#{repo.name}' failed. Would you like to continue anyway?".red)
|
9
9
|
break
|
10
10
|
end
|
data/lib/mgit/commands/grep.rb
CHANGED
data/lib/mgit/commands/help.rb
CHANGED
@@ -2,14 +2,14 @@ module MGit
|
|
2
2
|
class HelpCommand < Command
|
3
3
|
def execute(args)
|
4
4
|
if args.size == 0
|
5
|
-
|
5
|
+
pinfo "M[eta]Git - manage multiple git repositories at the same time"
|
6
6
|
puts
|
7
|
-
|
7
|
+
pinfo "Usage:"
|
8
8
|
Command.instance_each do |cmd|
|
9
|
-
|
9
|
+
pinfo "mgit #{cmd.usage}\n\t- #{cmd.description}"
|
10
10
|
end
|
11
11
|
else
|
12
|
-
|
12
|
+
pinfo Command.create(args[0]).help
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/lib/mgit/commands/list.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module MGit
|
2
2
|
class ListCommand < Command
|
3
3
|
def execute(args)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
puts "#{display} => #{repo.path}"
|
8
|
-
end
|
4
|
+
t = []
|
5
|
+
Registry.each { |repo| t << [repo.name, repo.path] }
|
6
|
+
ptable t, :columns => [24, nil]
|
9
7
|
end
|
10
8
|
|
11
9
|
def arity
|
data/lib/mgit/commands/log.rb
CHANGED
@@ -6,11 +6,11 @@ module MGit
|
|
6
6
|
uc = unmerged_commits(branch, upstream)
|
7
7
|
next if uc.empty?
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
pinfo "In repository #{repo.name}, branch #{upstream} the following commits were made:"
|
10
|
+
|
11
|
+
t = []
|
12
|
+
uc.each { |c| t << [c[:commit], c[:author], c[:subject]] }
|
13
|
+
ptable t
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/mgit/commands/remove.rb
CHANGED
data/lib/mgit/commands/status.rb
CHANGED
@@ -3,11 +3,9 @@ require 'set'
|
|
3
3
|
module MGit
|
4
4
|
class StatusCommand < Command
|
5
5
|
def execute(args)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
puts "#{display} => [#{flags(repo).to_a.join(', ')}]"
|
10
|
-
end
|
6
|
+
t = []
|
7
|
+
Registry.chdir_each { |repo| t << [repo.name, flags(repo).to_a.join(', ')] }
|
8
|
+
ptable t, :columns => [24, nil]
|
11
9
|
end
|
12
10
|
|
13
11
|
def arity
|
data/lib/mgit/output.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
module MGit
|
2
|
+
module Output
|
3
|
+
def pinfo(s)
|
4
|
+
puts s.green
|
5
|
+
end
|
6
|
+
|
7
|
+
def pwarn
|
8
|
+
puts s.yellow
|
9
|
+
end
|
10
|
+
|
11
|
+
def perror
|
12
|
+
puts s.red
|
13
|
+
end
|
14
|
+
|
15
|
+
def ptable(table, options = {})
|
16
|
+
puts TableOutputter.new(table, options).to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
class TableOutputter
|
22
|
+
attr_reader :table, :options
|
23
|
+
|
24
|
+
def initialize(table, options)
|
25
|
+
@table = table
|
26
|
+
@options = options
|
27
|
+
raise ImplementationError.new('ptable called with invalid table') unless valid_table?
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
cw = column_widths
|
32
|
+
|
33
|
+
if options[:columns]
|
34
|
+
options[:columns].each_with_index do |c, i|
|
35
|
+
cw[i] = c if c
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
table.map do |row|
|
40
|
+
row.map.with_index { |cell, i| justify(cell, cw[i]) }.join(' | ')
|
41
|
+
end.join("\n")
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def valid_table?
|
47
|
+
table.empty? || table.all? { |c| c.is_a?(Array) && c.size == table.first.size }
|
48
|
+
end
|
49
|
+
|
50
|
+
def columns
|
51
|
+
table.first.size
|
52
|
+
end
|
53
|
+
|
54
|
+
def column(nth)
|
55
|
+
table.map { |c| c[nth] }
|
56
|
+
end
|
57
|
+
|
58
|
+
def transpose
|
59
|
+
(0..(columns - 1)).map { |i| column(i) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def column_widths
|
63
|
+
transpose.map do |col|
|
64
|
+
col.map { |cell| cell.size }.max
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def justify(s, n)
|
69
|
+
(s.size > n) ? (s[0..(n - 3)] + '...') : s.ljust(n, ' ')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/mgit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FlavourSys Technology GmbH
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- lib/mgit/exceptions.rb
|
63
|
+
- lib/mgit/output.rb
|
63
64
|
- lib/mgit/cli.rb
|
64
65
|
- lib/mgit/command.rb
|
65
66
|
- lib/mgit/commands/clone.rb
|