mgit 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/mgit.rb +1 -0
- data/lib/mgit/commands/ffmerge.rb +2 -17
- data/lib/mgit/commands/log.rb +13 -26
- data/lib/mgit/commands/remove.rb +2 -3
- data/lib/mgit/registry.rb +1 -1
- data/lib/mgit/repository.rb +23 -8
- data/lib/mgit/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Yjg1YmQxYjM1YTZkYTU5Yzg0N2E4MzAwNWZmYTU3ZDQ0MTRhY2I0Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmJiYWNkNWNhYmUxMDQwYzBjYzg0Mjc0YjRhMDlkM2QxM2EzZWEzNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWI0ZWRhMWJiYWNjYmM0YTgyMDQyYzkwMjA1OWViY2U1MTY0MDRiN2RjZWY3
|
10
|
+
NDQ2ZTIzY2YzODQ5YmI2ZmRiMTkzMmIyM2YxODhhMmZmOTcxMGNlZjBjZDY3
|
11
|
+
MTI2MGFjNWNiOGM0ZGQ2MmVjOTMwOGU1MGU0NzljN2UwZjJlNjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTQ1MmI2NTA4OGQ2NDRlMjc4YTFlNGY4NWNmNDcwNDY0NjFmMWNkZWI2MDkz
|
14
|
+
ZTdmNjNiOGRmMzlhY2RmNTZmODJiOGNiOTY4MjFmYmIyMTU0ZTA3YjJmNTlh
|
15
|
+
ZjM2NzhhNmZhNWE4MGFiMzIwNzc5YTBhMmE5YWRmMjBmZjlhODc=
|
data/lib/mgit.rb
CHANGED
@@ -11,9 +11,8 @@ module MGit
|
|
11
11
|
|
12
12
|
puts "Fast-forward merging branches in repository #{repo.name}...".yellow
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
tb.each do |b|
|
14
|
+
cb = repo.current_branch
|
15
|
+
repo.remote_tracking_branches.each do |b, u|
|
17
16
|
`git checkout -q #{b}`
|
18
17
|
`git merge --ff-only @{u}`
|
19
18
|
end
|
@@ -30,19 +29,5 @@ module MGit
|
|
30
29
|
end
|
31
30
|
|
32
31
|
register_command :ffmerge
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def tracking_branches
|
37
|
-
`git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads`.
|
38
|
-
split("\n").
|
39
|
-
map { |b| b.split(' ') }.
|
40
|
-
reject { |b| b.size != 2 }.
|
41
|
-
map(&:first)
|
42
|
-
end
|
43
|
-
|
44
|
-
def current_branch
|
45
|
-
`git rev-parse --abbrev-ref HEAD`
|
46
|
-
end
|
47
32
|
end
|
48
33
|
end
|
data/lib/mgit/commands/log.rb
CHANGED
@@ -1,47 +1,34 @@
|
|
1
1
|
module MGit
|
2
2
|
class LogCommand < Command
|
3
3
|
def execute(args)
|
4
|
-
raise TooManyArgumentsError.new(self) if args.size > 1
|
5
|
-
|
6
|
-
days = 1
|
7
|
-
|
8
|
-
if args.size == 1
|
9
|
-
begin
|
10
|
-
days = Integer(args[0])
|
11
|
-
rescue ArgumentError => e
|
12
|
-
raise new CommandUsageError("First argument must be an integer", self)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
4
|
Registry.chdir_each do |repo|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
5
|
+
repo.remote_tracking_branches.each do |branch, upstream|
|
6
|
+
uc = unmerged_commits(branch, upstream)
|
7
|
+
next if uc.empty?
|
8
|
+
|
9
|
+
puts "In repository #{repo.name}, branch #{upstream} the following commits were made:".yellow
|
10
|
+
longest_name = uc.map { |c| c[:author].size }.max
|
11
|
+
uc.each do |c|
|
12
|
+
puts "#{c[:commit]} #{c[:author].ljust(longest_name, ' ')} #{c[:subject]}"
|
13
|
+
end
|
26
14
|
end
|
27
|
-
puts
|
28
15
|
end
|
29
16
|
end
|
30
17
|
|
31
18
|
def usage
|
32
|
-
'log
|
19
|
+
'log'
|
33
20
|
end
|
34
21
|
|
35
22
|
def description
|
36
|
-
'
|
23
|
+
'show unmerged commits for all remote-tracking branches'
|
37
24
|
end
|
38
25
|
|
39
26
|
register_command :log
|
40
27
|
|
41
28
|
private
|
42
29
|
|
43
|
-
def
|
44
|
-
`git log --pretty=format:"%h#%an#%s" --reverse
|
30
|
+
def unmerged_commits(branch, upstream)
|
31
|
+
`git log --pretty=format:"%h#%an#%s" --reverse --relative-date #{branch}..#{upstream}`.
|
45
32
|
split("\n").
|
46
33
|
map { |line| line.split('#') }.
|
47
34
|
map do |words|
|
data/lib/mgit/commands/remove.rb
CHANGED
@@ -12,9 +12,8 @@ module MGit
|
|
12
12
|
|
13
13
|
raise CommandUsageError.new("Couldn't find repository matching '#{ptrn}'.", self) unless repo
|
14
14
|
|
15
|
-
name
|
16
|
-
|
17
|
-
puts "Removed repository #{name}.".yellow
|
15
|
+
Registry.remove(repo.name)
|
16
|
+
puts "Removed repository #{repo.name}.".yellow
|
18
17
|
end
|
19
18
|
|
20
19
|
def usage
|
data/lib/mgit/registry.rb
CHANGED
data/lib/mgit/repository.rb
CHANGED
@@ -9,8 +9,19 @@ module MGit
|
|
9
9
|
@path = path
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def current_branch
|
13
|
+
in_repo { `git rev-parse --abbrev-ref HEAD` }
|
14
|
+
end
|
15
|
+
|
16
|
+
def remote_tracking_branches
|
17
|
+
a = in_repo do
|
18
|
+
`git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads`.
|
19
|
+
split("\n").
|
20
|
+
map { |b| b.split(' ') }.
|
21
|
+
reject { |b| b.size != 2 }
|
22
|
+
end
|
23
|
+
|
24
|
+
Hash[a]
|
14
25
|
end
|
15
26
|
|
16
27
|
def flags
|
@@ -50,18 +61,22 @@ module MGit
|
|
50
61
|
divergence
|
51
62
|
end
|
52
63
|
|
64
|
+
def dirty?
|
65
|
+
[:index, :dirty, :untracked].any? { |f| flags.include?(f) }
|
66
|
+
end
|
67
|
+
|
53
68
|
private
|
54
69
|
|
70
|
+
def in_repo
|
71
|
+
Dir.chdir(path) { yield }
|
72
|
+
end
|
73
|
+
|
55
74
|
def status
|
56
|
-
@status ||= `git status --short --branch --ignore-submodules`.split("\n")
|
75
|
+
@status ||= in_repo { `git status --short --branch --ignore-submodules`.split("\n") }
|
57
76
|
end
|
58
77
|
|
59
78
|
def status_lines
|
60
|
-
|
61
|
-
status.each do |s|
|
62
|
-
yield s
|
63
|
-
end
|
64
|
-
end
|
79
|
+
status.each { |s| yield s }
|
65
80
|
end
|
66
81
|
end
|
67
82
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FlavourSys Technology GmbH
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: xdg
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: M[eta]Git let's you manage multiple git repositories simultaneously
|
42
56
|
email: technology@flavoursys.com
|
43
57
|
executables:
|