git-superproject 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Brewfile +1 -0
- data/exe/git-superproject +4 -0
- data/lib/git/superproject.rb +23 -0
- data/lib/git/superproject/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6343023e6bcbde57e4072a5547ff41ffeb2f739
|
4
|
+
data.tar.gz: 55b82812f1debc5e7c3da6be71bfbdac93eafad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ee59a28ab4a7ab20838c9bf95d9ccb0a1552c2cb3c43c10f6cc7f03dddefb746597de1b84ac1137bb75c8f05f8dddaca584592cfc3fe453aa66c49facb0f7a
|
7
|
+
data.tar.gz: 10841cbbb1e767b1db74e7ec63c9b3b577bcd7c15008e211b19d5dc6e2a2503e34782d479f43b98a7ec0858de6645b45a0454c5e5a38a73ba364c225132d84a7
|
data/Brewfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
brew 'fzf'
|
data/exe/git-superproject
CHANGED
@@ -29,6 +29,10 @@ when /\A--/
|
|
29
29
|
when '--list' then config.list(name)
|
30
30
|
when '--add' then config.add(name, *ARGV)
|
31
31
|
when '--remove' then config.remove(name, *ARGV)
|
32
|
+
when '--edit'
|
33
|
+
finder = 'fzf --print0 --multi --border --height=50%'
|
34
|
+
candidates = ARGF.readlines.map(&:strip) # repos to select from...
|
35
|
+
config.edit(name, finder, candidates)
|
32
36
|
else
|
33
37
|
abort \
|
34
38
|
"Unknown 'git superproject' command: #{command}\n\n" \
|
data/lib/git/superproject.rb
CHANGED
@@ -6,6 +6,7 @@ require 'English'
|
|
6
6
|
require 'pathname'
|
7
7
|
require 'tempfile'
|
8
8
|
require 'fileutils'
|
9
|
+
require 'io/console'
|
9
10
|
|
10
11
|
class Set
|
11
12
|
def to_json(*args)
|
@@ -59,6 +60,28 @@ module Git
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
63
|
+
def edit(name, finder, candidates = [])
|
64
|
+
log_to(IO.console, name)
|
65
|
+
|
66
|
+
tempfile = Tempfile.new('superproject_')
|
67
|
+
tempfile.write(candidates.join($RS))
|
68
|
+
tempfile.close # also ensures flushing!
|
69
|
+
|
70
|
+
until (repos = `#{finder} < #{tempfile.path}`.strip).empty?
|
71
|
+
repos.split("\0").each do |repo|
|
72
|
+
if repos_for(name).include? repo
|
73
|
+
IO.console.puts "Removing #{repo} from #{name}..."
|
74
|
+
remove_from(name, repo)
|
75
|
+
else
|
76
|
+
IO.console.puts "Adding #{repo} to #{name}..."
|
77
|
+
add_to(name, repo)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
log_to(IO.console, name)
|
83
|
+
end
|
84
|
+
|
62
85
|
def save(file)
|
63
86
|
# create backup of original file
|
64
87
|
FileUtils.mv(file, "#{file}~") if File.exist? file
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Vandenberk
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".rubocop.yml"
|
80
80
|
- ".ruby-version"
|
81
81
|
- ".travis.yml"
|
82
|
+
- Brewfile
|
82
83
|
- Gemfile
|
83
84
|
- README.md
|
84
85
|
- Rakefile
|