mgit 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mgit/appdata.rb +104 -0
- data/lib/mgit/cli.rb +5 -0
- data/lib/mgit/command.rb +7 -5
- data/lib/mgit/commands/head.rb +23 -0
- data/lib/mgit/commands/remove_all.rb +24 -0
- data/lib/mgit/output.rb +2 -1
- data/lib/mgit/registry.rb +6 -8
- data/lib/mgit/repository.rb +4 -0
- data/lib/mgit/version.rb +1 -1
- data/lib/mgit.rb +1 -0
- metadata +6 -5
- data/lib/mgit/commands/config.rb +0 -0
- data/lib/mgit/subcommand.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72da3e471054578d574fab47f09886ebdf696676
|
4
|
+
data.tar.gz: 889b8f08aa19321f4162aceddb7e9b0e4beca58c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe550448650a1c9cc3530e1cf583423771a7630b4c11069051ba8743c269abdc2f1dbfbc91db07bcd31049d8c66dab4f036f64047797d650461ddadeb60bd675
|
7
|
+
data.tar.gz: 6ca1f337596f69e8ec7f223857c8b2b1715bed676c9a3dc47849a138e9c7c57f169700b54ccbc6c6acf1a029ae250643377f29963eeef4667c4d00f9340297c2
|
data/lib/mgit/appdata.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module MGit
|
5
|
+
module AppData
|
6
|
+
|
7
|
+
####################
|
8
|
+
# Module interface #
|
9
|
+
####################
|
10
|
+
|
11
|
+
def self.update
|
12
|
+
if AppDataVersion.active
|
13
|
+
AppDataVersion.updates.each { |u| u.migrate! }
|
14
|
+
else
|
15
|
+
AppDataVersion.latest.setup
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.load(key, default = {})
|
20
|
+
AppDataVersion.latest.load(key, default)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.save!(key, value)
|
24
|
+
AppDataVersion.latest.save!(key, value)
|
25
|
+
end
|
26
|
+
|
27
|
+
#########################################
|
28
|
+
# Base class for data storage versions. #
|
29
|
+
#########################################
|
30
|
+
|
31
|
+
class AppDataVersion
|
32
|
+
@@versions = []
|
33
|
+
|
34
|
+
def self.inherited(version)
|
35
|
+
@@versions << version.new
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.sorted
|
40
|
+
@@versions.sort_by { |v| v.version }
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.updates
|
44
|
+
self.sorted.drop_while { |v| !v.active? }.drop(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.active
|
48
|
+
self.sorted.find { |v| v.active? }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.latest
|
52
|
+
self.sorted.last
|
53
|
+
end
|
54
|
+
|
55
|
+
include Comparable
|
56
|
+
|
57
|
+
def <=>(other)
|
58
|
+
version <=> other.version
|
59
|
+
end
|
60
|
+
|
61
|
+
[:version, :active?, :load, :save!, :migrate!].each do |meth|
|
62
|
+
define_method(meth) do
|
63
|
+
raise ImplementationError.new("AppDataVersion #{self.class.name} doesn't implement the #{meth.to_s} method.")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
#######################################################################
|
69
|
+
# Original version, plain YAML file containing the repositories hash. #
|
70
|
+
#######################################################################
|
71
|
+
|
72
|
+
class LegacyAppData < AppDataVersion
|
73
|
+
def version
|
74
|
+
0
|
75
|
+
end
|
76
|
+
|
77
|
+
def active?
|
78
|
+
File.file?(repofile)
|
79
|
+
end
|
80
|
+
|
81
|
+
def load(key, default)
|
82
|
+
raise ImplementationError.new('LegacyAppData::load called with unknown key.') if key != :repositories
|
83
|
+
repos = YAML.load_file(repofile)
|
84
|
+
repos ? repos : default
|
85
|
+
end
|
86
|
+
|
87
|
+
def save!(key, value)
|
88
|
+
raise ImplementationError.new('LegacyAppData::save! called with unknown key.') if key != :repositories
|
89
|
+
File.open(repofile, 'w') { |fd| fd.write value.to_yaml }
|
90
|
+
end
|
91
|
+
|
92
|
+
def setup
|
93
|
+
FileUtils.touch(repofile)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def repofile
|
99
|
+
XDG['CONFIG_HOME'].to_path.join('mgit.yml')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
data/lib/mgit/cli.rb
CHANGED
@@ -4,6 +4,11 @@ module MGit
|
|
4
4
|
|
5
5
|
def start
|
6
6
|
raise NoCommandError if ARGV.size == 0
|
7
|
+
|
8
|
+
# Initialize AppData and migrate if necessary.
|
9
|
+
AppData.update
|
10
|
+
|
11
|
+
# Run command, consuming its name from the list of arguments.
|
7
12
|
command = Command.execute(ARGV.shift, ARGV)
|
8
13
|
rescue UsageError => e
|
9
14
|
perror e.to_s
|
data/lib/mgit/command.rb
CHANGED
@@ -7,11 +7,7 @@ module MGit
|
|
7
7
|
|
8
8
|
def self.execute(name, args)
|
9
9
|
cmd = self.create(name)
|
10
|
-
|
11
|
-
arity_min, arity_max = cmd.arity
|
12
|
-
raise TooFewArgumentsError.new(cmd) if arity_min && args.size < arity_min
|
13
|
-
raise TooManyArgumentsError.new(cmd) if arity_max && args.size > arity_max
|
14
|
-
|
10
|
+
cmd.check_arity(args)
|
15
11
|
cmd.execute(args)
|
16
12
|
end
|
17
13
|
|
@@ -33,6 +29,12 @@ module MGit
|
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
32
|
+
def check_arity(args)
|
33
|
+
arity_min, arity_max = self.arity
|
34
|
+
raise TooFewArgumentsError.new(self) if arity_min && args.size < arity_min
|
35
|
+
raise TooManyArgumentsError.new(self) if arity_max && args.size > arity_max
|
36
|
+
end
|
37
|
+
|
36
38
|
[:arity, :usage, :help, :description].each do |meth|
|
37
39
|
define_method(meth) do
|
38
40
|
raise ImplementationError.new("Command #{self.class.name} doesn't implement the #{meth.to_s} method.")
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module MGit
|
2
|
+
class ListCommand < Command
|
3
|
+
def execute(args)
|
4
|
+
t = []
|
5
|
+
Registry.each { |repo| t << [repo.name, repo.current_branch, repo.current_head] }
|
6
|
+
ptable t, :columns => [24, nil, nil]
|
7
|
+
end
|
8
|
+
|
9
|
+
def arity
|
10
|
+
[0, 0]
|
11
|
+
end
|
12
|
+
|
13
|
+
def usage
|
14
|
+
'head'
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
'show repository HEADs'
|
19
|
+
end
|
20
|
+
|
21
|
+
register_command :head
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MGit
|
2
|
+
class RemoveAllCommand < Command
|
3
|
+
def execute(args)
|
4
|
+
if agree('This will delete all repositories from mgit. Are you sure?'.red)
|
5
|
+
Registry.clean
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def arity
|
10
|
+
[0, 0]
|
11
|
+
end
|
12
|
+
|
13
|
+
def usage
|
14
|
+
'removeall'
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
'removes all repositories from mgit (resets mgit\'s store)'
|
19
|
+
end
|
20
|
+
|
21
|
+
register_command :removeall
|
22
|
+
register_alias :remove_all
|
23
|
+
end
|
24
|
+
end
|
data/lib/mgit/output.rb
CHANGED
data/lib/mgit/registry.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
module MGit
|
4
2
|
module Registry
|
5
3
|
def self.all
|
@@ -34,18 +32,18 @@ module MGit
|
|
34
32
|
self.save! repos
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
def self.repofile
|
40
|
-
XDG['CONFIG_HOME'].to_path.join('mgit.yml')
|
35
|
+
def self.clean
|
36
|
+
self.save!({})
|
41
37
|
end
|
42
38
|
|
39
|
+
private
|
40
|
+
|
43
41
|
def self.load
|
44
|
-
|
42
|
+
AppData.load(:repositories)
|
45
43
|
end
|
46
44
|
|
47
45
|
def self.save!(repos)
|
48
|
-
|
46
|
+
AppData.save!(:repositories, repos)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
data/lib/mgit/repository.rb
CHANGED
data/lib/mgit/version.rb
CHANGED
data/lib/mgit.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FlavourSys Technology GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -77,14 +77,15 @@ files:
|
|
77
77
|
- lib/mgit/output.rb
|
78
78
|
- lib/mgit/repository.rb
|
79
79
|
- lib/mgit/version.rb
|
80
|
-
- lib/mgit/
|
80
|
+
- lib/mgit/appdata.rb
|
81
81
|
- lib/mgit/registry.rb
|
82
82
|
- lib/mgit/exceptions.rb
|
83
83
|
- lib/mgit/commands/list.rb
|
84
84
|
- lib/mgit/commands/grep.rb
|
85
|
-
- lib/mgit/commands/
|
85
|
+
- lib/mgit/commands/remove_all.rb
|
86
86
|
- lib/mgit/commands/version.rb
|
87
87
|
- lib/mgit/commands/fetch.rb
|
88
|
+
- lib/mgit/commands/head.rb
|
88
89
|
- lib/mgit/commands/status.rb
|
89
90
|
- lib/mgit/commands/remove.rb
|
90
91
|
- lib/mgit/commands/help.rb
|
@@ -116,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
117
|
version: '0'
|
117
118
|
requirements: []
|
118
119
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.0.
|
120
|
+
rubygems_version: 2.0.14
|
120
121
|
signing_key:
|
121
122
|
specification_version: 4
|
122
123
|
summary: MGit meta repository tool
|
data/lib/mgit/commands/config.rb
DELETED
File without changes
|