git-superproject 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/git-superproject +3 -3
- data/lib/git/superproject/version.rb +1 -1
- data/lib/git/superproject.rb +22 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3f7f4ea1344e3c900ced70c849a94fc33f9bf82
|
4
|
+
data.tar.gz: ad9c632d59f4970f723468dcbdd943f4bd61e8f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187035ebd0b53cd3b119be692321e6999685f540ff402e0976ea206a29bd83dab2f8996f46f091674abe2f665760403458b3b0d7c7acdb9058943cce1ff820db
|
7
|
+
data.tar.gz: de3aac2d24eca3c4d72489ee6aa07ac41ee51ee9e8d9564800e4a1ae4035330507c9a2b36e4ae095ff5230fd12a92053d6a33175ab851b86e4408ecc9de8eb17
|
data/exe/git-superproject
CHANGED
@@ -26,9 +26,9 @@ when /\A--/
|
|
26
26
|
exit(-1)
|
27
27
|
end
|
28
28
|
case command
|
29
|
-
when '--list' then
|
30
|
-
when '--add' then
|
31
|
-
when '--remove' then
|
29
|
+
when '--list' then config.list(name)
|
30
|
+
when '--add' then config.add(name, *ARGV)
|
31
|
+
when '--remove' then config.remove(name, *ARGV)
|
32
32
|
else
|
33
33
|
abort \
|
34
34
|
"Unknown 'git superproject' command: #{command}\n\n" \
|
data/lib/git/superproject.rb
CHANGED
@@ -4,8 +4,15 @@ require 'set'
|
|
4
4
|
require 'json'
|
5
5
|
require 'English'
|
6
6
|
require 'pathname'
|
7
|
+
require 'tempfile'
|
7
8
|
require 'fileutils'
|
8
9
|
|
10
|
+
class Set
|
11
|
+
def to_json(*args)
|
12
|
+
to_a.to_json(*args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
9
16
|
module Git
|
10
17
|
|
11
18
|
HOME = Pathname.new(Dir.home)
|
@@ -37,21 +44,19 @@ module Git
|
|
37
44
|
end
|
38
45
|
|
39
46
|
def list(name)
|
40
|
-
|
47
|
+
log_to($stdout, name)
|
41
48
|
end
|
42
49
|
|
43
50
|
def add(name, *repos)
|
44
51
|
repos.each do |repo|
|
45
52
|
add_to(name, repo)
|
46
53
|
end
|
47
|
-
list(name)
|
48
54
|
end
|
49
55
|
|
50
56
|
def remove(name, *repos)
|
51
57
|
repos.each do |repo|
|
52
58
|
remove_from(name, repo)
|
53
59
|
end
|
54
|
-
list(name)
|
55
60
|
end
|
56
61
|
|
57
62
|
def save(file)
|
@@ -90,9 +95,22 @@ module Git
|
|
90
95
|
@superprojects[name].delete(repo)
|
91
96
|
end
|
92
97
|
|
98
|
+
def repos_for(name)
|
99
|
+
@superprojects[name].to_a.sort
|
100
|
+
end
|
101
|
+
|
102
|
+
def log_to(io, name)
|
103
|
+
return unless io.tty?
|
104
|
+
|
105
|
+
config = Tempfile.new("#{name}_")
|
106
|
+
write_to(config.path, name)
|
107
|
+
|
108
|
+
io.write(File.read(config))
|
109
|
+
end
|
110
|
+
|
93
111
|
def write_to(file, name)
|
94
112
|
key = "superproject.#{name}.repo"
|
95
|
-
|
113
|
+
repos_for(name).each do |repo|
|
96
114
|
`git config --file #{file} --add #{key} #{repo}`
|
97
115
|
end
|
98
116
|
end
|