While at it, make it use class methods instead; no reason to instantiate
an object for this.
Eventually there should be some functional tests for the individual
strategies as well.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
By default, git checks out the fetched ref after cloning the repo, but
this is unnecessary as we explicitly check out the desired ref during
staging. This also silences some unnecessarily confusing output.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
"git status -s" is used to detect if the repository was corrupted during
an interrupted clone, but it can leak output to the terminal, so use
quiet_system.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Two wrapper scripts that find git and svn using the ENV variables we support and then searching through the PATH and looking inside Xcode.app if necessary.
Now just calling git or svn in Homebrew code will find and exec the right tool and we can stop fussing.
Apologies to @adamv who is probably unimpressed that the cmds directory has non-commands in it now. If it's consolation these are temporary pending some more work on superenv whereby some more directories are created under the superenv root.
Now that a URL, version, and the (for lack of a better term) "specs"
associated with said URL (e.g. the VCS revision, or a download strategy
hint) are neatly bundled up in a SoftwareSpec object, it doesn't make
sense to pass them individually to download strategy constructors. These
constructors now take only the formula name and a SoftwareSpec as
parameters.
This allows us to move mirror handling out out of Formula#fetch and into
the download strategies themselves. While doing so, we adjust the mirror
implementation a bit; mirrors now assume the same "specs" as their
owner's URL. They are still only useable by the CurlDownloadStrategy,
but this provides a basis for extending mirror support to other
strategies.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
'which' only returns a Pathname or nil, and doesn't care about anything
sent to stderr, so just silence it by default and combine the two
methods.
ClosesHomebrew/homebrew#12115.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
The --depth option is apparently more nuanced that I had originally
thought, and while it does not actually break repositories, repeatedly
using "--depth 1" can cause problems depending on the structure of the
history.
Luckily, we don't actually need it to prevent the entire repository from
being fetched as long as the fetch respec is set correctly, which we do
since 7718c939b06987ff8f1ecd599c8ace6f998ce180.
FixesHomebrew/homebrew#12024.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
git-clone's --single-branch is too new, and Xcode 4.3's stock git
doesn't have it. Since we don't require git from Homebrew, don't use it.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
The current series of fetch invocations in GitDownloadStrategy has the
unfortunate behavior of fetching full history even in shallow clones
that only need the history between the clone point and the remote HEAD.
It should be possible to determine if it is actually necessary to fetch
the full history, including all tags, and if it is not to avoid this
overhead.
FixesHomebrew/homebrew#11958, and several other recurring problems.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
GIT_DIR is convenient, but it does not work when both a formula and
subformula try to stage a git checkout, as git will use the main
formula's repository when staging the subformula.
Stop setting it, and restore the kludge to the git-multipush formula.
FixesHomebrew/homebrew#10893.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
We now read six bytes instead of four in order to detect xz compression;
this broke rar detection which used a string literal instead of a regexp
for comparison.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Some build scripts want to inspect the git history, e.g. to determine
version strings. Rather than copy the repository into the build tree,
just setting GIT_DIR is enough for things to "just work".
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Rationale: some software (e.g. GNU Coreutils, GnuTLS 3.x), have started
distributing _only_ xz-compressed tarballs. There is no system XZ
utility provided by OS X, but it is necessary so that we can continue to
provide formulae for this software.
If XZUtils isn't installed, we abort and prompt the user to `brew
install xz`.
The `xz` command itself doesn't do any untarring, so we write the
decompressed archive to stdout and pipe it to tar.