brew unpack: support -gpf
-g sets up git repo. -f forces even if already there. I found these useful.
This commit is contained in:
parent
4973329a60
commit
9ac477b07c
@ -30,7 +30,7 @@ class Formula
|
|||||||
# so that paching only happens if the user asks.
|
# so that paching only happens if the user asks.
|
||||||
alias do_patch patch
|
alias do_patch patch
|
||||||
def patch
|
def patch
|
||||||
if ARGV.include? '--patch'
|
if ARGV.flag? '--patch'
|
||||||
# Yes Ruby, we are about to redefine a constant. Just breathe.
|
# Yes Ruby, we are about to redefine a constant. Just breathe.
|
||||||
orig_v = $VERBOSE; $VERBOSE = nil
|
orig_v = $VERBOSE; $VERBOSE = nil
|
||||||
Formula.const_set 'DATA', ScriptDataReader.load(path)
|
Formula.const_set 'DATA', ScriptDataReader.load(path)
|
||||||
@ -48,19 +48,18 @@ end
|
|||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
def unpack
|
def unpack
|
||||||
unpack_usage = <<-EOS
|
unpack_usage = <<-EOS
|
||||||
Usage: brew unpack [--patch] [--destdir=path/to/extract/in] <formulae ...>
|
Usage: brew unpack [-pg] [--destdir=path/to/extract/in] <formulae ...>
|
||||||
|
|
||||||
Unpack formulae source code for inspection.
|
Unpack formulae source code for inspection.
|
||||||
|
|
||||||
Formulae archives will be extracted to subfolders inside the current working
|
Formulae archives will be extracted to subfolders inside the current working
|
||||||
directory or a directory specified by `--destdir`. If the `--patch` option is
|
directory or a directory specified by `--destdir`. If the `-p` option is
|
||||||
supplied, patches will also be downloaded and applied.
|
supplied, patches will also be downloaded and applied. If the `-g` option is
|
||||||
|
specified a git repository is created and all files added so that you can diff
|
||||||
|
changes.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
if ARGV.empty?
|
abort unpack_usage if ARGV.empty?
|
||||||
puts unpack_usage
|
|
||||||
exit 0
|
|
||||||
end
|
|
||||||
|
|
||||||
formulae = ARGV.formulae
|
formulae = ARGV.formulae
|
||||||
raise FormulaUnspecifiedError if formulae.empty?
|
raise FormulaUnspecifiedError if formulae.empty?
|
||||||
@ -78,11 +77,26 @@ supplied, patches will also be downloaded and applied.
|
|||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
# Create a nice name for the stage folder.
|
# Create a nice name for the stage folder.
|
||||||
stage_dir = unpack_dir + [f.name, f.version].join('-')
|
stage_dir = unpack_dir + [f.name, f.version].join('-')
|
||||||
raise "Destination #{stage_dir} allready exists!" if stage_dir.exist?
|
|
||||||
|
|
||||||
|
if stage_dir.exist?
|
||||||
|
raise "Destination #{stage_dir} allready exists!" unless ARGV.force?
|
||||||
|
rm_rf stage_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
oh1 "Unpacking #{f.name} to: #{stage_dir}"
|
||||||
|
ENV['VERBOSE'] = '1' # show messages about tar
|
||||||
f.brew do
|
f.brew do
|
||||||
oh1 "Unpacking #{f.name} to: #{stage_dir}"
|
cd Dir['*'][0] if Dir['*'].one?
|
||||||
cp_r Dir.getwd, stage_dir
|
mv getwd, stage_dir
|
||||||
|
end
|
||||||
|
ENV['VERBOSE'] = nil
|
||||||
|
|
||||||
|
if ARGV.switch? 'g'
|
||||||
|
ohai "Setting up git repository"
|
||||||
|
cd stage_dir
|
||||||
|
system "git init -q"
|
||||||
|
system "git add -A"
|
||||||
|
system 'git commit -qm"Vanilla"'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user