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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3f7f4ea1344e3c900ced70c849a94fc33f9bf82
4
- data.tar.gz: ad9c632d59f4970f723468dcbdd943f4bd61e8f5
3
+ metadata.gz: b6343023e6bcbde57e4072a5547ff41ffeb2f739
4
+ data.tar.gz: 55b82812f1debc5e7c3da6be71bfbdac93eafad5
5
5
  SHA512:
6
- metadata.gz: 187035ebd0b53cd3b119be692321e6999685f540ff402e0976ea206a29bd83dab2f8996f46f091674abe2f665760403458b3b0d7c7acdb9058943cce1ff820db
7
- data.tar.gz: de3aac2d24eca3c4d72489ee6aa07ac41ee51ee9e8d9564800e4a1ae4035330507c9a2b36e4ae095ff5230fd12a92053d6a33175ab851b86e4408ecc9de8eb17
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" \
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Git
2
2
  module Superproject
3
3
  NAME = 'git-superproject'.freeze
4
- VERSION = '0.2.2'.freeze
4
+ VERSION = '1.0.0'.freeze
5
5
  end
6
6
  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.2
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