diff options
| author | Mike McQuaid | 2014-09-24 21:35:07 -0700 |
|---|---|---|
| committer | Mike McQuaid | 2014-10-02 16:03:23 -0700 |
| commit | 26c76381c873a389f36bc7531cdf940a246ef831 (patch) | |
| tree | fc796e825263ae389c435e7a0f8f4e2a89f2191a /Library/ENV/scm/git | |
| parent | cf41b57fe6588a30644eaa9204cc8668d3d7cc9e (diff) | |
| download | brew-26c76381c873a389f36bc7531cdf940a246ef831.tar.bz2 | |
Move SCM wrappers from Contributions to ENV/scm.
Closes Homebrew/homebrew#32615.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/ENV/scm/git')
| -rwxr-xr-x | Library/ENV/scm/git | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Library/ENV/scm/git b/Library/ENV/scm/git new file mode 100755 index 000000000..888a6ff11 --- /dev/null +++ b/Library/ENV/scm/git @@ -0,0 +1,51 @@ +#!/usr/bin/ruby -W0 +# This script because we support $GIT, $HOMEBREW_SVN, etc. and Xcode-only +# configurations. Order is careful to be what the user would want. + +F = File.basename(__FILE__).freeze +D = File.expand_path(File.dirname(__FILE__)).freeze + +def exec *args + # prevent fork-bombs + arg0 = if args.size == 1 + args.first.split(' ') + else + args + end.first + return if arg0 =~ /^#{F}/i + return if File.expand_path(arg0) == File.expand_path(__FILE__) + + if args[1] == '-print-path' and File.executable? args[0] + puts args[0] + exit 0 + else + Kernel.exec *args + end +end + +case F.downcase + when 'git' then %W{HOMEBREW_GIT GIT} + when 'svn' then %W{HOMEBREW_SVN} + else [] +end.each do |key| + exec ENV[key], *ARGV if ENV[key] and File.executable? ENV[key] +end + +brew_version = File.expand_path("#{D}/../../../bin/#{F}") +exec brew_version, *ARGV if File.executable? brew_version + +`/usr/bin/which -a #{F} 2>/dev/null`.split("\n").each do |path| + exec path, *ARGV +end + +# xcrun hangs if xcode-select is set to "/" +path = `/usr/bin/xcode-select -print-path 2>/dev/null`.chomp +if path != "/" + path = `/usr/bin/xcrun -find #{F} 2>/dev/null`.chomp + exec path, *ARGV if File.executable? path +end + +path = "/Applications/Xcode.app/Contents/Developer/usr/bin/#{F}" +exec path, *ARGV if File.executable? path + +abort "You must: brew install #{F}" |
