git-superproject 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a09b0b6841e89f8a79c70c9725cbe8c27d378430
4
- data.tar.gz: 6ce5c12bb293926a99aff78ad5f30ab6e75b461e
3
+ metadata.gz: e3f7f4ea1344e3c900ced70c849a94fc33f9bf82
4
+ data.tar.gz: ad9c632d59f4970f723468dcbdd943f4bd61e8f5
5
5
  SHA512:
6
- metadata.gz: 4b75807381c1a981f5682f53c90452341898ec9cd89548de931df35f227bd0d73e9ca568d0fe6f6925852e33a9bf4b458d5e17b099f8f39177e6daeb4737491d
7
- data.tar.gz: b1568599d2a18a884df07099ca2b7d3c124fe86fe21dd56fc580a9c716aadcc0fc4bbc5ea4cd8ce6fea7611f4d2770f923611c7dde929128e7c4840f6190ec01
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 puts config.list(name).to_json
30
- when '--add' then puts config.add(name, *ARGV).to_json
31
- when '--remove' then puts config.remove(name, *ARGV).to_json
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" \
@@ -1,6 +1,6 @@
1
1
  module Git
2
2
  module Superproject
3
3
  NAME = 'git-superproject'.freeze
4
- VERSION = '0.2.1'.freeze
4
+ VERSION = '0.2.2'.freeze
5
5
  end
6
6
  end
@@ -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
- @superprojects[name].to_a.sort
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
- list(name).each do |repo|
113
+ repos_for(name).each do |repo|
96
114
  `git config --file #{file} --add #{key} #{repo}`
97
115
  end
98
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-superproject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenberk