File tree 3 files changed +26
-3
lines changed
3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 9
9
.DS_Store
10
10
/Library /LinkedKegs
11
11
/Library /Taps
12
+ /Library /Formula /.gitignore
Original file line number Diff line number Diff line change
1
+ require 'tempfile'
2
+
1
3
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY /"Library"
2
4
3
5
module Homebrew extend self
@@ -19,12 +21,23 @@ def install_tap user, repo
19
21
raise "Already tapped!" if tapd . directory?
20
22
abort unless system "git clone https://github.com/#{ user } /homebrew-#{ repo } #{ tapd } "
21
23
24
+ gitignores = ( HOMEBREW_LIBRARY /"Formula/.gitignore" ) . read . split rescue [ ]
25
+
22
26
cd HOMEBREW_LIBRARY /"Formula"
23
27
tapd . find_formula do |relative_pathname |
24
28
# using the system ln is the only way to get relative symlinks
25
29
system "ln -s ../Taps/#{ user } -#{ repo } /#{ relative_pathname } 2>/dev/null"
26
- opoo "#{ relative_pathname . basename ( ".rb" ) } conflicts" unless $?. success?
30
+ if $?. success?
31
+ gitignores << relative_pathname . basename . to_s
32
+ else
33
+ opoo "#{ relative_pathname . basename , ".rb" } conflicts"
34
+ end
27
35
end
36
+
37
+ tf = Tempfile . new ( "brew-tap" )
38
+ tf . write ( gitignores . uniq . join ( "\n " ) )
39
+ tf . close
40
+ mv tf . path , "#{ HOMEBREW_PREFIX } /Library/Formula/.gitignore"
28
41
end
29
42
30
43
private
Original file line number Diff line number Diff line change 1
1
require 'cmd/tap' # for Pathname.recursive_formula
2
+ require 'tempfile'
2
3
3
4
module Homebrew extend self
4
5
def untap
@@ -7,11 +8,19 @@ def untap
7
8
8
9
raise "No such tap!" unless tapd . directory?
9
10
11
+ gitignores = ( HOMEBREW_PREFIX /"Library/Formula/.gitignore" ) . read . split rescue [ ]
12
+
10
13
tapd . find_formula do |pn |
11
- pn = HOMEBREW_REPOSITORY /"Library/Formula" /pn . basename
14
+ bn = pn . basename . to_s
15
+ pn = HOMEBREW_REPOSITORY /"Library/Formula" /bn
12
16
pn . delete if pn . symlink? and pn . realpath . to_s =~ %r[^#{ tapd . realpath } ]
17
+ gitignores . delete ( bn )
13
18
end
14
-
15
19
rm_rf tapd
20
+
21
+ tf = Tempfile . new ( "brew-untap" )
22
+ tf . write ( gitignores . join ( "\n " ) )
23
+ tf . close
24
+ mv tf . path , "#{ HOMEBREW_PREFIX } /Library/Formula/.gitignore"
16
25
end
17
26
end
You can’t perform that action at this time.
0 commit comments