birkirb-git 1.1.1 → 1.1.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.
- data/lib/git/submodule.rb +63 -0
- data/lib/git/submodules.rb +43 -0
- metadata +6 -5
@@ -0,0 +1,63 @@
|
|
1
|
+
module Git
|
2
|
+
class Submodule < Path
|
3
|
+
|
4
|
+
STATUS_MATCH = /(^.)(\w*?)\s(.*?)\s?(\(.*\))?$/
|
5
|
+
|
6
|
+
attr_accessor :path, :description, :commitish
|
7
|
+
|
8
|
+
def initialize(base, path)
|
9
|
+
@path = path
|
10
|
+
@base = base
|
11
|
+
set_with_status(self.status)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
@path
|
16
|
+
end
|
17
|
+
|
18
|
+
def status
|
19
|
+
@base.lib.submodule_status(@path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def init
|
23
|
+
@base.lib.submodule_init(@path)
|
24
|
+
set_with_status(self.status)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
@base.lib.submodule_update(@path)
|
29
|
+
set_with_status(self.status)
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialized?
|
33
|
+
@state != '-'
|
34
|
+
end
|
35
|
+
|
36
|
+
def updated?
|
37
|
+
@state == ' '
|
38
|
+
end
|
39
|
+
|
40
|
+
def uri
|
41
|
+
self.init unless self.initialized?
|
42
|
+
@base.config("submodule.#{path}.url")
|
43
|
+
end
|
44
|
+
|
45
|
+
def repository
|
46
|
+
Git.open(File.join(@base.dir.to_s, self.path))
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def set_with_status(status)
|
52
|
+
status = status.match(STATUS_MATCH)
|
53
|
+
if status && 5 == status.size && path == status[3]
|
54
|
+
@state = status[1]
|
55
|
+
@commitish = status[2]
|
56
|
+
@description = status[4]
|
57
|
+
else
|
58
|
+
raise 'Submodule not found'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Git
|
2
|
+
|
3
|
+
# object that holds all available submodules
|
4
|
+
class Submodules
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(base)
|
8
|
+
@submodules = {}
|
9
|
+
|
10
|
+
@base = base
|
11
|
+
|
12
|
+
@base.lib.submodule_status.split('\n').each do |status|
|
13
|
+
s = status.match(Submodule::STATUS_MATCH)
|
14
|
+
if s
|
15
|
+
@submodules[s[3]] = Git::Submodule.new(@base, s[3])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# array like methods
|
21
|
+
|
22
|
+
def size
|
23
|
+
@submodules.size
|
24
|
+
end
|
25
|
+
|
26
|
+
def each(&block)
|
27
|
+
@submodules.values.each(&block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](symbol)
|
31
|
+
@submodules[symbol.to_s]
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
out = ''
|
36
|
+
@submodules.each do |k, s|
|
37
|
+
out << s.status
|
38
|
+
end
|
39
|
+
out
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birkirb-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon
|
8
|
-
- Birkir A. Barkarson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-21 00:00:00 -07:00
|
14
13
|
default_executable:
|
15
14
|
dependencies: []
|
16
15
|
|
17
16
|
description:
|
18
|
-
email: schacon@gmail.com
|
17
|
+
email: schacon@gmail.com
|
19
18
|
executables: []
|
20
19
|
|
21
20
|
extensions: []
|
@@ -39,10 +38,12 @@ files:
|
|
39
38
|
- lib/git/stash.rb
|
40
39
|
- lib/git/stashes.rb
|
41
40
|
- lib/git/status.rb
|
41
|
+
- lib/git/submodule.rb
|
42
|
+
- lib/git/submodules.rb
|
42
43
|
- lib/git/working_directory.rb
|
43
44
|
- README
|
44
45
|
has_rdoc: true
|
45
|
-
homepage: http://github.com/
|
46
|
+
homepage: http://github.com/schacon/ruby-git
|
46
47
|
post_install_message:
|
47
48
|
rdoc_options:
|
48
49
|
- --charset=UTF-8
|