From 26c76381c873a389f36bc7531cdf940a246ef831 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 24 Sep 2014 21:35:07 -0700 Subject: Move SCM wrappers from Contributions to ENV/scm. Closes Homebrew/homebrew#32615. Signed-off-by: Mike McQuaid --- Library/Contributions/cmd/git | 51 ------------------------------------------- Library/Contributions/cmd/svn | 1 - Library/ENV/4.3/git | 2 +- Library/ENV/4.3/svn | 2 +- Library/ENV/scm/git | 51 +++++++++++++++++++++++++++++++++++++++++++ Library/ENV/scm/svn | 1 + Library/brew.rb | 4 +++- 7 files changed, 57 insertions(+), 55 deletions(-) delete mode 100755 Library/Contributions/cmd/git delete mode 120000 Library/Contributions/cmd/svn create mode 100755 Library/ENV/scm/git create mode 120000 Library/ENV/scm/svn (limited to 'Library') diff --git a/Library/Contributions/cmd/git b/Library/Contributions/cmd/git deleted file mode 100755 index 888a6ff11..000000000 --- a/Library/Contributions/cmd/git +++ /dev/null @@ -1,51 +0,0 @@ -#!/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}" diff --git a/Library/Contributions/cmd/svn b/Library/Contributions/cmd/svn deleted file mode 120000 index 0899c2993..000000000 --- a/Library/Contributions/cmd/svn +++ /dev/null @@ -1 +0,0 @@ -git \ No newline at end of file diff --git a/Library/ENV/4.3/git b/Library/ENV/4.3/git index 96b4ab213..ba71181a5 120000 --- a/Library/ENV/4.3/git +++ b/Library/ENV/4.3/git @@ -1 +1 @@ -../../Contributions/cmd/git \ No newline at end of file +../scm/git \ No newline at end of file diff --git a/Library/ENV/4.3/svn b/Library/ENV/4.3/svn index b20ea6a2a..e1231dfaa 120000 --- a/Library/ENV/4.3/svn +++ b/Library/ENV/4.3/svn @@ -1 +1 @@ -../../Contributions/cmd/svn \ No newline at end of file +../scm/svn \ No newline at end of file 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}" diff --git a/Library/ENV/scm/svn b/Library/ENV/scm/svn new file mode 120000 index 000000000..0899c2993 --- /dev/null +++ b/Library/ENV/scm/svn @@ -0,0 +1 @@ +git \ No newline at end of file diff --git a/Library/brew.rb b/Library/brew.rb index cd2be0774..422fd2c7b 100755 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -108,11 +108,13 @@ begin end # Add contributed commands to PATH before checking. - ENV['PATH'] += "#{File::PATH_SEPARATOR}#{HOMEBREW_CONTRIB}/cmd" Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/cmd"].each do |tap_cmd_dir| ENV["PATH"] += "#{File::PATH_SEPARATOR}#{tap_cmd_dir}" end + # Add SCM wrappers. + ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_LIBRARY}/ENV/scm" + internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd) if cmd # Usage instructions should be displayed if and only if one of: -- cgit v1.2.3