language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
Homebrew
brew
ce7b32cec835bb658df75a0c691db9a97921163c.json
add HOMEBREW_ENV_PATH internal variable `Library/ENV` like `Library/Homebrew` is part of Homebrew basecode. It should be able to be accessed during the `brew tests`. By adding HOMEBREW_ENV_PATH variable, we allow test suit to locate these codes.
Library/brew.rb
@@ -50,7 +50,7 @@ def require?(path) end # Add SCM wrappers. - ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_LIBRARY}/ENV/scm" + ENV["PATH"] += "#{File::PATH_SEPARATOR}#{HOMEBREW_ENV_PATH}/scm" if cmd internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd)
true
Other
Homebrew
brew
28b4923dad7a421f6f6d2598a5661a147268a4c7.json
fix tests for deprecating SHA1 Closes Homebrew/homebrew#50272. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_checksum.rb
@@ -3,16 +3,16 @@ class ChecksumTests < Homebrew::TestCase def test_empty? - assert_empty Checksum.new(:sha1, "") + assert_empty Checksum.new(:sha256, "") end def test_equality - a = Checksum.new(:sha1, TEST_SHA1) - b = Checksum.new(:sha1, TEST_SHA1) + a = Checksum.new(:sha256, TEST_SHA256) + b = Checksum.new(:sha256, TEST_SHA256) assert_equal a, b - a = Checksum.new(:sha1, TEST_SHA1) - b = Checksum.new(:sha1, TEST_SHA1.reverse) + a = Checksum.new(:sha256, TEST_SHA256) + b = Checksum.new(:sha256, TEST_SHA256.reverse) refute_equal a, b a = Checksum.new(:sha1, TEST_SHA1)
true
Other
Homebrew
brew
28b4923dad7a421f6f6d2598a5661a147268a4c7.json
fix tests for deprecating SHA1 Closes Homebrew/homebrew#50272. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_checksum_verification.rb
@@ -21,22 +21,6 @@ def teardown @_f.clear_cache end - def test_good_sha1 - formula do - sha1 TESTBALL_SHA1 - end - - assert_checksum_good - end - - def test_bad_sha1 - formula do - sha1 "7ea8a98acb8f918df723c2ae73fe67d5664bfd7e" - end - - assert_checksum_bad - end - def test_good_sha256 formula do sha256 TESTBALL_SHA256
true
Other
Homebrew
brew
28b4923dad7a421f6f6d2598a5661a147268a4c7.json
fix tests for deprecating SHA1 Closes Homebrew/homebrew#50272. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_formula.rb
@@ -159,7 +159,7 @@ def test_formula_spec_integration homepage "http://example.com" url "http://example.com/test-0.1.tbz" mirror "http://example.org/test-0.1.tbz" - sha1 TEST_SHA1 + sha256 TEST_SHA256 head "http://example.com/test.git", :tag => "foo"
true
Other
Homebrew
brew
28b4923dad7a421f6f6d2598a5661a147268a4c7.json
fix tests for deprecating SHA1 Closes Homebrew/homebrew#50272. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_formula_spec_selection.rb
@@ -38,7 +38,7 @@ def test_selects_head_when_exclusive def test_incomplete_spec_not_selected f = formula { - sha1 TEST_SHA1 + sha256 TEST_SHA256 version "1.0" head "foo" } @@ -48,7 +48,7 @@ def test_incomplete_spec_not_selected def test_incomplete_stable_not_set f = formula { - sha1 TEST_SHA1 + sha256 TEST_SHA256 devel { url "foo-1.1a" } head "foo" }
true
Other
Homebrew
brew
28b4923dad7a421f6f6d2598a5661a147268a4c7.json
fix tests for deprecating SHA1 Closes Homebrew/homebrew#50272. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_resource.rb
@@ -94,8 +94,6 @@ def test_mirrors def test_checksum_setters assert_nil @resource.checksum - @resource.sha1(TEST_SHA1) - assert_equal Checksum.new(:sha1, TEST_SHA1), @resource.checksum @resource.sha256(TEST_SHA256) assert_equal Checksum.new(:sha256, TEST_SHA256), @resource.checksum end @@ -120,7 +118,7 @@ def test_verify_download_integrity_missing def test_verify_download_integrity_mismatch fn = stub(:file? => true) - checksum = @resource.sha1(TEST_SHA1) + checksum = @resource.sha256(TEST_SHA256) fn.expects(:verify_checksum).with(checksum). raises(ChecksumMismatchError.new(fn, checksum, Object.new))
true
Other
Homebrew
brew
28b4923dad7a421f6f6d2598a5661a147268a4c7.json
fix tests for deprecating SHA1 Closes Homebrew/homebrew#50272. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_software_spec.rb
@@ -155,19 +155,19 @@ def setup def test_checksum_setters checksums = { - :snow_leopard_32 => "deadbeef"*5, - :snow_leopard => "faceb00c"*5, - :lion => "baadf00d"*5, - :mountain_lion => "8badf00d"*5 + :snow_leopard_32 => "deadbeef"*8, + :snow_leopard => "faceb00c"*8, + :lion => "baadf00d"*8, + :mountain_lion => "8badf00d"*8 } - checksums.each_pair do |cat, sha1| - @spec.sha1(sha1 => cat) + checksums.each_pair do |cat, digest| + @spec.sha256(digest => cat) end - checksums.each_pair do |cat, sha1| + checksums.each_pair do |cat, digest| checksum, = @spec.checksum_for(cat) - assert_equal Checksum.new(:sha1, sha1), checksum + assert_equal Checksum.new(:sha256, digest), checksum end end
true
Other
Homebrew
brew
8aaa95ee993187f763b0953d3720b5f6308472d3.json
Add advice about keychain credentials Fixes Homebrew/homebrew#50050. Closes Homebrew/homebrew#50059.
Library/Homebrew/utils.rb
@@ -487,7 +487,7 @@ def initialize(reset, error) GitHub #{error} Try again in #{pretty_ratelimit_reset(reset)}, or create a personal access token: #{Tty.em}https://github.com/settings/tokens/new?scopes=&description=Homebrew#{Tty.reset} - and then set the token as: HOMEBREW_GITHUB_API_TOKEN + and then set the token as: export HOMEBREW_GITHUB_API_TOKEN="your_new_token" EOS end @@ -498,11 +498,20 @@ def pretty_ratelimit_reset(reset) class AuthenticationFailedError < Error def initialize(error) - super <<-EOS.undent - GitHub #{error} - HOMEBREW_GITHUB_API_TOKEN may be invalid or expired, check: + message = "GitHub #{error}\n" + if ENV["HOMEBREW_GITHUB_API_TOKEN"] + message << <<-EOS.undent + HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check: #{Tty.em}https://github.com/settings/tokens#{Tty.reset} - EOS + EOS + else + message << <<-EOS.undent + The GitHub credentials in the OS X keychain are invalid. + Clear them with: + printf "protocol=https\\nhost=github.com\\n" | git credential-osxkeychain erase + EOS + end + super message end end
false
Other
Homebrew
brew
f30221c7e1d626ddce3d923bc9da2ba880a7ceee.json
Tips & Tricks: remove obsolete ref to SHA1
share/doc/homebrew/Tips-N'-Tricks.md
@@ -75,7 +75,7 @@ renaming the file from <code>otp_src_R13B03</code> to download. This means instead of manually renaming a formula, you can run `mv the_tarball $(brew --cache -s $FORMULA)`. -You can also pre-cache the download by using the command `brew fetch formula` which also displays the SHA1 and SHA256 values. This can be useful for updating formulae to new versions. +You can also pre-cache the download by using the command `brew fetch formula` which also displays the SHA256 value. This can be useful for updating formulae to new versions. ## Using Homebrew behind a proxy
false
Other
Homebrew
brew
148da475710b882a17e044153102961919c48477.json
Improve error message for invalid regex to search Fixes https://github.com/Homebrew/homebrew/issues/50131 This commit removes the error backtrace and improves the error message if a bad regexp is passed to `brew search`. Closes Homebrew/homebrew#50173. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Library/Homebrew/cmd/search.rb
@@ -93,6 +93,8 @@ def query_regexp(query) when %r{^/(.*)/$} then Regexp.new($1) else /.*#{Regexp.escape(query)}.*/i end + rescue RegexpError + odie "#{query} is not a valid regex" end def search_taps(rx)
false
Other
Homebrew
brew
f30c264519afd98b5aac8dd5c48810c761983124.json
Avoid pathological trailing slash Resolves an issue where xcode-select output with a terminal slash leads to superenv failing to strip system library paths from ccld-style invocations. Fixes Homebrew/homebrew#49731. Discussion in Homebrew/homebrew#50154.
Library/Homebrew/os/mac/xcode.rb
@@ -43,7 +43,8 @@ def prefix path = bundle_path path.join("Contents", "Developer") if path else - Pathname.new(dir) + # Use cleanpath to avoid pathological trailing slash + Pathname.new(dir).cleanpath end end end
false
Other
Homebrew
brew
90246be60a6ba46e07b5ab65ced53b1290b98ab9.json
Formula Cookbook: note $HOME override See https://github.com/Homebrew/homebrew/pull/50130#discussion_r56254860
share/doc/homebrew/Formula-Cookbook.md
@@ -241,7 +241,15 @@ Check the top of the e.g. `./configure` output. Some configure scripts do not re Please add a [`test do`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#test-class_method) block to the formula. This will be run by `brew test foo` and the [Brew Test Bot](Brew-Test-Bot.md). -The [`test do`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#test-class_method) block automatically creates and changes to a temporary directory which is deleted after run. You can access this [`Pathname`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Pathname) with the [`testpath`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#testpath-instance_method) function. +The +[`test do`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#test-class_method) +block automatically creates and changes to a temporary directory which +is deleted after run. You can access this +[`Pathname`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Pathname) +with the +[`testpath`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#testpath-instance_method) +function. The environment variable `HOME` is set to `testpath` within +the `test do` block. We want tests that don't require any user input and test the basic functionality of the application. For example `foo build-foo input.foo` is a good test and (despite their widespread use) `foo --version` and `foo --help` are bad tests. However, a bad test is better than no test at all.
false
Other
Homebrew
brew
236a18debe51e815f2d81a43d2151c500555abf9.json
audit: fix crash when HOMEBREW_NO_GITHUB_API is set Running brew audit --strict --online on a formula with a GitHub homepage/url would crash if HOMEBREW_NO_GITHUB_API is set because GitHub.repository returns `nil` and the audit code assumes it always returns a hash. Closes Homebrew/homebrew#50054. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/cmd/audit.rb
@@ -509,6 +509,8 @@ def audit_github_repository return end + return if metadata.nil? + problem "GitHub fork (not canonical repository)" if metadata["fork"] if (metadata["forks_count"] < 20) && (metadata["subscribers_count"] < 20) && (metadata["stargazers_count"] < 50)
true
Other
Homebrew
brew
236a18debe51e815f2d81a43d2151c500555abf9.json
audit: fix crash when HOMEBREW_NO_GITHUB_API is set Running brew audit --strict --online on a formula with a GitHub homepage/url would crash if HOMEBREW_NO_GITHUB_API is set because GitHub.repository returns `nil` and the audit code assumes it always returns a hash. Closes Homebrew/homebrew#50054. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/test/test_cmd_audit.rb
@@ -340,4 +340,21 @@ def test_audit_line_default_template assert_equal "Please remove default template comments", fa.problems.shift end + + def test_audit_github_repository_no_api + fa = formula_auditor "foo", <<-EOS.undent, :strict => true, :online => true + class Foo < Formula + homepage "https://github.com/example/example" + url "http://example.com/foo-1.0.tgz" + end + EOS + + original_value = ENV["HOMEBREW_NO_GITHUB_API"] + ENV["HOMEBREW_NO_GITHUB_API"] = "1" + + fa.audit_github_repository + assert_equal [], fa.problems + ensure + ENV["HOMEBREW_NO_GITHUB_API"] = original_value + end end
true
Other
Homebrew
brew
1e1184fc2d7bae278b2806ddda296e26dcc9fe97.json
superenv: fix make_jobs regular expression HOMEBREW_MAKE_JOBS can be a multidigit number. The regex should match the entire number not just the last digit. Closes Homebrew/homebrew#50016. Signed-off-by: Tim D. Smith <git@tim-smith.us>
Library/Homebrew/extend/ENV/super.rb
@@ -263,7 +263,7 @@ def deparallelize alias_method :j1, :deparallelize def make_jobs - self["MAKEFLAGS"] =~ /-\w*j(\d)+/ + self["MAKEFLAGS"] =~ /-\w*j(\d+)/ [$1.to_i, 1].max end
false
Other
Homebrew
brew
e8caa48cc2858815ef3193d461fb12c2ba8bda07.json
brew.sh: add tap-pin to sudo check list
Library/brew.sh
@@ -146,7 +146,7 @@ fi if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] then case "$HOMEBREW_COMMAND" in - install|reinstall|postinstall|link|pin|update|upgrade|create|migrate|tap|switch) + install|reinstall|postinstall|link|pin|update|upgrade|create|migrate|tap|tap-pin|switch) odie <<EOS Cowardly refusing to 'sudo brew $HOMEBREW_COMMAND' You can use brew with sudo, but only if the brew executable is owned by root.
false
Other
Homebrew
brew
ec2a3f979ee81e5ed5d5368a6addbe9b31eb3ece.json
utils: use string arg to IO.popen. Closes Homebrew/homebrew#49882.
Library/Homebrew/utils.rb
@@ -511,7 +511,7 @@ def api_credentials if ENV["HOMEBREW_GITHUB_API_TOKEN"] ENV["HOMEBREW_GITHUB_API_TOKEN"] else - github_credentials = IO.popen(["git", "credential-osxkeychain", "get"], "w+") do |io| + github_credentials = IO.popen("git credential-osxkeychain get", "w+") do |io| io.puts "protocol=https\nhost=github.com" io.close_write io.read
false
Other
Homebrew
brew
16f8b16f190f92bd9f4af3db5464fc924bdcd854.json
blacklist: suggest Cask for installing mactex Closes Homebrew/homebrew#49817. Signed-off-by: Alex Dunn <adunn@ucsb.edu>
Library/Homebrew/blacklist.rb
@@ -8,6 +8,10 @@ def blacklisted?(name) and only builds 32-bit (and thus can't use Homebrew deps on Snow Leopard.) We recommend using a MacTeX distribution: https://www.tug.org/mactex/ + + You can install it using Cask: + + brew cask install mactex EOS when "pip" then <<-EOS.undent Homebrew provides pip via: `brew install python`. However you will then
false
Other
Homebrew
brew
0578ba0f429708773489fdd8f9647c2712c7025c.json
install_renamed: handle recursive installs. Closes Homebrew/homebrew#49845. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/extend/pathname.rb
@@ -82,6 +82,7 @@ def install_p(src, new_basename) src = Pathname(src) dst = join(new_basename) dst = yield(src, dst) if block_given? + return unless dst mkpath
true
Other
Homebrew
brew
0578ba0f429708773489fdd8f9647c2712c7025c.json
install_renamed: handle recursive installs. Closes Homebrew/homebrew#49845. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/install_renamed.rb
@@ -2,7 +2,8 @@ module InstallRenamed def install_p(_, new_basename) super do |src, dst| if src.directory? - dst + dst.install(src.children) + next else append_default_if_different(src, dst) end
true
Other
Homebrew
brew
0578ba0f429708773489fdd8f9647c2712c7025c.json
install_renamed: handle recursive installs. Closes Homebrew/homebrew#49845. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/test/test_pathname.rb
@@ -137,6 +137,16 @@ def test_install_renamed_directory assert_equal "a", File.read(@dst+@src.basename+@file.basename) end + def test_install_renamed_directory_recursive + @dst.extend(InstallRenamed) + (@dst+@dir.basename).mkpath + (@dst+@dir.basename+"another_file").write "a" + @dir.mkpath + (@dir+"another_file").write "b" + @dst.install @dir + assert_equal "b", File.read(@dst+@dir.basename+"another_file.default") + end + def test_cp_path_sub_file @file.write "a" @file.cp_path_sub @src, @dst
true
Other
Homebrew
brew
6f9f3faef3d566641b3fa18e887819da7889018a.json
test-bot: fix wrong tap argument check
Library/Homebrew/cmd/test-bot.rb
@@ -49,15 +49,15 @@ def resolve_test_tap bot_argv = ENV["UPSTREAM_BOT_PARAMS"].split " " bot_argv.extend HomebrewArgvExtension if tap = bot_argv.value("tap") - return Tap.fetch(tap) if url_path =~ HOMEBREW_TAP_REGEX + return Tap.fetch(tap) end end if git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"] # Also can get tap from Jenkins GIT_URL. url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(%r{\.git$}, "") begin - return Tap.fetch(url_path) + return Tap.fetch(url_path) if url_path =~ HOMEBREW_TAP_REGEX rescue end end
false
Other
Homebrew
brew
9f96e41b40f52313fbc7832df631827f5e3bcacb.json
tap: add methods to get git related information These methods will be used in `brew --version`, `brew config` and `brew doctor` after core/formula separation. Closes Homebrew/homebrew#49796. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/tap.rb
@@ -83,7 +83,7 @@ def clear_cache # e.g. `https://github.com/user/homebrew-repo` def remote @remote ||= if installed? - if git? + if git? && Utils.git_available? path.cd do Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp end @@ -98,6 +98,34 @@ def git? (path/".git").exist? end + # git HEAD for this {Tap}. + def git_head + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle } + end + + # git HEAD in short format for this {Tap}. + def git_short_head + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD").chuzzle } + end + + # time since git last commit for this {Tap}. + def git_last_commit + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle } + end + + # git last commit date for this {Tap}. + def git_last_commit_date + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD").chuzzle } + end + # The issues URL of this {Tap}. # e.g. `https://github.com/user/homebrew-repo/issues` def issues_url
true
Other
Homebrew
brew
9f96e41b40f52313fbc7832df631827f5e3bcacb.json
tap: add methods to get git related information These methods will be used in `brew --version`, `brew config` and `brew doctor` after core/formula separation. Closes Homebrew/homebrew#49796. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/test_tap.rb
@@ -1,6 +1,8 @@ require "testing_env" class TapTest < Homebrew::TestCase + include FileUtils + def setup @path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" @path.mkpath @@ -16,7 +18,7 @@ class Foo < Formula EOS @alias_file = @path/"Aliases/bar" @alias_file.parent.mkpath - FileUtils.ln_s @formula_file, @alias_file + ln_s @formula_file, @alias_file (@path/"formula_renames.json").write <<-EOS.undent { "oldname": "foo" } EOS @@ -25,14 +27,21 @@ class Foo < Formula EOS @cmd_file = @path/"cmd/brew-tap-cmd.rb" @cmd_file.parent.mkpath - FileUtils.touch @cmd_file - FileUtils.chmod 0755, @cmd_file + touch @cmd_file + chmod 0755, @cmd_file @manpage_file = @path/"man/man1/brew-tap-cmd.1" @manpage_file.parent.mkpath - FileUtils.touch @manpage_file + touch @manpage_file end def setup_git_repo + env = ENV.to_hash + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + @path.cd do shutup do system "git", "init" @@ -41,6 +50,8 @@ def setup_git_repo system "git", "commit", "-m", "init" end end + ensure + ENV.replace(env) end def teardown @@ -74,7 +85,7 @@ def test_issues_url t = Tap.new("someone", "foo") path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" path.mkpath - FileUtils.cd path do + cd path do shutup { system "git", "init" } system "git", "remote", "add", "origin", "https://github.com/someone/homebrew-foo" @@ -123,6 +134,26 @@ def test_remote refute_predicate version_tap, :private? end + def test_remote_not_git_repo + assert_nil @tap.remote + end + + def test_remote_git_not_available + setup_git_repo + Utils.stubs(:git_available?).returns(false) + assert_nil @tap.remote + end + + def test_git_variant + touch @path/"README" + setup_git_repo + + assert_equal "e1893a6bd191ba895c71b652ff8376a6114c7fa7", @tap.git_head + assert_equal "e189", @tap.git_short_head + assert_match %r{years ago}, @tap.git_last_commit + assert_equal "2009-05-21", @tap.git_last_commit_date + end + def test_private_remote skip "HOMEBREW_GITHUB_API_TOKEN is required" unless ENV["HOMEBREW_GITHUB_API_TOKEN"] assert_predicate @tap, :private? @@ -174,6 +205,8 @@ def test_pin_and_unpin end class CoreFormulaRepositoryTest < Homebrew::TestCase + include FileUtils + def setup @repo = CoreFormulaRepository.new end @@ -204,7 +237,7 @@ class Foo < Formula EOS @alias_file = @repo.alias_dir/"bar" @alias_file.parent.mkpath - FileUtils.ln_s @formula_file, @alias_file + ln_s @formula_file, @alias_file assert_equal [@formula_file], @repo.formula_files assert_equal ["foo"], @repo.formula_names
true
Other
Homebrew
brew
57a81f9e22ef2db7fefc432adafe2d63a2206bc8.json
Clarify case conventions in formula naming If a formula's class name contains an uppercase-spelled acronym, the messages given by `brew install` can be pretty confusing (it recommends a formula named exactly the same…) Closes Homebrew/homebrew#49639. Signed-off-by: Tim D. Smith <git@tim-smith.us>
share/doc/homebrew/Formula-Cookbook.md
@@ -272,7 +272,7 @@ When importing classes, Homebrew will require the formula and then create an ins * `foo-bar.rb` => `FooBar` * `foobar.rb` => `Foobar` -Thus, if you change the name of the class, you must also rename the file. Filenames should be all lowercase. +Thus, if you change the name of the class, you must also rename the file. Filenames should be all lowercase, and class names should be the strict CamelCase equivalent, e.g. formulae `gnu-go` and `sdl_mixer` become classes `GnuGo` and `SdlMixer`, even if part of their name is an acronym. Add aliases by creating symlinks in `Library/Aliases`.
false
Other
Homebrew
brew
76767f3d6e89e540241e973b8ffe04690a9a2ccb.json
Formula-Cookbook: Improve testing suggestions Based on recent feedback on some pull requests, I touched up the section about adding tests to formula. I wanted to make it clearer that the examples demonstrate how to create files on the fly and add a pointer to the tinyxml2 formula (DomT4 pointed it out to me as a good example). Closes Homebrew/homebrew#49641. Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
share/doc/homebrew/Formula-Cookbook.md
@@ -245,7 +245,7 @@ The [`test do`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula# We want tests that don't require any user input and test the basic functionality of the application. For example `foo build-foo input.foo` is a good test and (despite their widespread use) `foo --version` and `foo --help` are bad tests. However, a bad test is better than no test at all. -See [cmake](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/cmake.rb) for an example of a formula with a good test. A basic `CMakeLists.txt` file is written CMake uses it to generate Makefiles. This test checks that CMake doesn't e.g. segfault during basic operation. +See [cmake](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/cmake.rb) for an example of a formula with a good test. The formula writes a basic `CMakeLists.txt` file into the test directory then calls CMake to generate Makefiles. This test checks that CMake doesn't e.g. segfault during basic operation. Another good example is [tinyxml2](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/tinyxml2.rb), which writes a small C++ source file into the test directory, compiles and links it against the tinyxml2 library and finally checks that the resulting program runs successfully. ## Manuals
false
Other
Homebrew
brew
b4edf23a3624d062fe030a57ad0b2ea1e6b339be.json
test-bot: make bottle stats visible by default Closes Homebrew/homebrew#49620.
Library/Homebrew/cmd/test-bot.rb
@@ -805,9 +805,14 @@ def test_ci_upload(tap) unless formula_packaged[formula_name] package_url = "#{bintray_repo_url}/#{bintray_package}" unless system "curl", "--silent", "--fail", "--output", "/dev/null", package_url + package_blob = <<-EOS.undent + {"name": "#{bintray_package}", + "public_download_numbers": true, + "public_stats": true} + EOS curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", "-H", "Content-Type: application/json", - "-d", "{\"name\":\"#{bintray_package}\"}", bintray_repo_url + "-d", package_blob, bintray_repo_url puts end formula_packaged[formula_name] = true
false
Other
Homebrew
brew
bd679c7dc38c06eed8014ef074241836ce605508.json
brew.sh: improve empty argument handling Follow-up to Homebrew/homebrew#49327 that leaves empty argument handling to the Ruby code (it is a bit more sophisticated and distinguished between `help` and an empty argument list and treats them differently) instead of hard-wiring the former to the `help` command. Closes Homebrew/homebrew#49538. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Library/brew.sh
@@ -117,10 +117,10 @@ then set -- "$@" -v fi +HOMEBREW_ARG_COUNT="$#" HOMEBREW_COMMAND="$1" shift case "$HOMEBREW_COMMAND" in - '') HOMEBREW_COMMAND="help";; ls) HOMEBREW_COMMAND="list";; homepage) HOMEBREW_COMMAND="home";; -S) HOMEBREW_COMMAND="search";; @@ -169,5 +169,7 @@ then source "$HOMEBREW_BASH_COMMAND" { "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; } else - exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$HOMEBREW_COMMAND" "$@" + # Unshift command back into argument list (unless argument list was empty). + [[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@" + exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$@" fi
false
Other
Homebrew
brew
2ab4f7452702dd89c6e6457b7dc2cccb5da65263.json
brew.sh: drop reference to removed 'update-ruby' This is a follow-up fix to a minor oversight in Homebrew/homebrew#49523.
Library/brew.sh
@@ -146,7 +146,7 @@ fi if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] then case "$HOMEBREW_COMMAND" in - install|reinstall|postinstall|link|pin|update|update-ruby|upgrade|create|migrate|tap|switch) + install|reinstall|postinstall|link|pin|update|upgrade|create|migrate|tap|switch) odie <<EOS Cowardly refusing to 'sudo brew $HOMEBREW_COMMAND' You can use brew with sudo, but only if the brew executable is owned by root.
false
Other
Homebrew
brew
43c6061bc95d8e21803b227181f716e6926e28f4.json
Tap#install: support quiet option
Library/Homebrew/tap.rb
@@ -140,17 +140,21 @@ def core_formula_repository? # @param [Hash] options # @option options [String] :clone_targe If passed, it will be used as the clone remote. # @option options [Boolean] :full_clone If set as true, full clone will be used. + # @option options [Boolean] :quiet If set, suppress all output. def install(options = {}) require "descriptions" raise TapAlreadyTappedError, name if installed? clear_cache + quiet = options.fetch(:quiet, false) + # ensure git is installed Utils.ensure_git_installed! - ohai "Tapping #{name}" + ohai "Tapping #{name}" unless quiet remote = options[:clone_target] || "https://github.com/#{user}/homebrew-#{repo}" args = %W[clone #{remote} #{path}] args << "--depth=1" unless options.fetch(:full_clone, false) + args << "-q" if quiet begin safe_system "git", *args @@ -165,10 +169,10 @@ def install(options = {}) link_manpages formula_count = formula_files.size - puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" + puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" unless quiet Descriptions.cache_formulae(formula_names) - if !options[:clone_target] && private? + if !options[:clone_target] && private? && !quiet puts <<-EOS.undent It looks like you tapped a private repository. To avoid entering your credentials each time you update, you can use git HTTP credential
false
Other
Homebrew
brew
b52af53e711d442f2b7097a449a6c077664eb7f3.json
various: use Tap abstraction formula_rename and tap_migrations are now handled inside Tap. Closes Homebrew/homebrew#49549. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/cmd/audit.rb
@@ -4,10 +4,8 @@ require "extend/ENV" require "formula_cellar_checks" require "official_taps" -require "tap_migrations" require "cmd/search" require "date" -require "formula_renames" module Homebrew def audit @@ -898,11 +896,11 @@ def audit_caveats end def audit_reverse_migration - # Only enforce for new formula being re-added to core + # Only enforce for new formula being re-added to core and official taps return unless @strict - return unless formula.core_formula? + return unless formula.tap && formula.tap.official? - if TAP_MIGRATIONS.key?(formula.name) + if formula.tap.tap_migrations.key?(formula.name) problem <<-EOS.undent #{formula.name} seems to be listed in tap_migrations.rb! Please remove #{formula.name} from present tap & tap_migrations.rb
true
Other
Homebrew
brew
b52af53e711d442f2b7097a449a6c077664eb7f3.json
various: use Tap abstraction formula_rename and tap_migrations are now handled inside Tap. Closes Homebrew/homebrew#49549. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/cmd/migrate.rb
@@ -1,5 +1,4 @@ require "migrator" -require "formula_renames" module Homebrew def migrate
true
Other
Homebrew
brew
b52af53e711d442f2b7097a449a6c077664eb7f3.json
various: use Tap abstraction formula_rename and tap_migrations are now handled inside Tap. Closes Homebrew/homebrew#49549. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/formula.rb
@@ -11,7 +11,6 @@ require "pkg_version" require "tap" require "core_formula_repository" -require "formula_renames" require "keg" require "migrator"
true
Other
Homebrew
brew
b52af53e711d442f2b7097a449a6c077664eb7f3.json
various: use Tap abstraction formula_rename and tap_migrations are now handled inside Tap. Closes Homebrew/homebrew#49549. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/formulary.rb
@@ -1,5 +1,4 @@ require "digest/md5" -require "formula_renames" require "tap" require "core_formula_repository"
true
Other
Homebrew
brew
b52af53e711d442f2b7097a449a6c077664eb7f3.json
various: use Tap abstraction formula_rename and tap_migrations are now handled inside Tap. Closes Homebrew/homebrew#49549. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/migrator.rb
@@ -2,7 +2,6 @@ require "formula_lock" require "keg" require "tab" -require "tap_migrations" class Migrator class MigrationNeededError < RuntimeError @@ -126,13 +125,11 @@ def from_same_taps? if formula.tap == old_tap true # Homebrew didn't use to update tabs while performing tap-migrations, - # so there can be INSTALL_RECEIPT's containing wrong information about - # tap (tap is Homebrew/homebrew if installed formula migrates to a tap), so - # we check if there is an entry about oldname migrated to tap and if + # so there can be INSTALL_RECEIPT's containing wrong information about tap, + # so we check if there is an entry about oldname migrated to tap and if # newname's tap is the same as tap to which oldname migrated, then we # can perform migrations and the taps for oldname and newname are the same. - elsif TAP_MIGRATIONS && (rec = TAP_MIGRATIONS[formula.oldname]) \ - && formula.tap == rec && old_tap == "Homebrew/homebrew" + elsif formula.tap && old_tap && formula.tap == old_tap.tap_migrations[formula.oldname] fix_tabs true else
true
Other
Homebrew
brew
ba147818cb4144e579a35cac949ca97b1253d50e.json
test_formulary: use CoreFormulaRepository abstraction
Library/Homebrew/test/test_formulary.rb
@@ -16,7 +16,7 @@ def test_class_naming class FormularyFactoryTest < Homebrew::TestCase def setup @name = "testball_bottle" - @path = HOMEBREW_PREFIX/"Library/Formula/#{@name}.rb" + @path = CoreFormulaRepository.new.formula_dir/"#{@name}.rb" @bottle_dir = Pathname.new("#{File.expand_path("..", __FILE__)}/bottles") @bottle = @bottle_dir/"testball_bottle-0.1.#{bottle_tag}.bottle.tar.gz" @path.write <<-EOS.undent @@ -144,7 +144,7 @@ def test_factory_ambiguity_tap_formulae class FormularyTapPriorityTest < Homebrew::TestCase def setup @name = "foo" - @core_path = HOMEBREW_PREFIX/"Library/Formula/#{@name}.rb" + @core_path = CoreFormulaRepository.new.formula_dir/"#{@name}.rb" @tap = Tap.new "homebrew", "foo" @tap_path = @tap.path/"#{@name}.rb" code = <<-EOS.undent
false
Other
Homebrew
brew
9a4987533af8207041c8061a36661286a429003d.json
update-report: fix new_full_name in report
Library/Homebrew/cmd/update-report.rb
@@ -128,7 +128,7 @@ def report if tap.core_formula_repository? new_full_name = new_name else - new_full_name = "#{tap}/#{new_full_name}" + new_full_name = "#{tap}/#{new_name}" end renamed_formulae << [old_full_name, new_full_name] if @report[:A].include? new_full_name
false
Other
Homebrew
brew
849e62c7368cf9d927448548b52387dc0e96c9ce.json
update-report: use tap inside Reporter * Avoid tons of unnecessary file path manipulation. Use abstraction offered by Tap class if possible. * Handle formula rename/tap migration inside reporter in per tap basis. * Avoid duplicated computation. * Remove redundant/dead code.
Library/Homebrew/cmd/update-report.rb
@@ -115,119 +115,143 @@ def load_formula_renames end class Reporter - attr_reader :initial_revision, :current_revision, :repository - - def self.repository_variable(repository) - if repository == HOMEBREW_REPOSITORY - "" - else - repository.to_s. - strip_prefix(Tap::TAP_DIRECTORY.to_s). - tr("^A-Za-z0-9", "_"). - upcase + class ReporterRevisionUnsetError < RuntimeError + def initialize(var_name) + super "#{var_name} is unset!" end end - def initialize(repository) - @repository = repository + attr_reader :tap, :initial_revision, :current_revision + + def initialize(tap) + @tap = tap - repo_var = Reporter.repository_variable(@repository) initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{repo_var}" @initial_revision = ENV[initial_revision_var].to_s - if @initial_revision.empty? - raise "#{initial_revision_var} is unset!" if ARGV.homebrew_developer? - raise "update-report should not be called directly!" - end + raise ReporterRevisionUnsetError, initial_revision_var if @initial_revision.empty? current_revision_var = "HOMEBREW_UPDATE_AFTER#{repo_var}" @current_revision = ENV[current_revision_var].to_s - if @current_revision.empty? - raise "#{current_revision_var} is unset!" if ARGV.homebrew_developer? - raise "update-report should not be called directly!" - end + raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty? end def report - map = Hash.new { |h, k| h[k] = [] } - - if initial_revision && initial_revision != current_revision - wc_revision = read_current_revision - - diff.each_line do |line| - status, *paths = line.split - src = paths.first - dst = paths.last - - next unless File.extname(dst) == ".rb" - next unless paths.any? { |p| File.dirname(p) == formula_directory } - - case status - when "A", "D" - map[status.to_sym] << repository.join(src) - when "M" - file = repository.join(src) - begin - formula = Formulary.factory(file) - new_version = if wc_revision == current_revision - formula.pkg_version - else - FormulaVersions.new(formula).formula_at_revision(@current_revision, &:pkg_version) - end - old_version = FormulaVersions.new(formula).formula_at_revision(@initial_revision, &:pkg_version) - next if new_version == old_version - # short term fix to prevent situation like https://github.com/Homebrew/homebrew/issues/45616 - rescue Exception => e - onoe e if ARGV.homebrew_developer? - end - map[:M] << file - when /^R\d{0,3}/ - map[:D] << repository.join(src) if File.dirname(src) == formula_directory - map[:A] << repository.join(dst) if File.dirname(dst) == formula_directory + return @report if @report + + @report = Hash.new { |h, k| h[k] = [] } + return @report unless updated? + + diff.each_line do |line| + status, *paths = line.split + src = Pathname.new paths.first + dst = Pathname.new paths.last + + next unless dst.extname == ".rb" + next unless paths.any? { |p| tap.formula_file?(p) } + + case status + when "A", "D" + @report[status.to_sym] << tap.formula_file_to_name(src) + when "M" + begin + formula = Formulary.factory(tap.path/src) + new_version = formula.pkg_version + old_version = FormulaVersions.new(formula).formula_at_revision(@initial_revision, &:pkg_version) + next if new_version == old_version + rescue Exception => e + onoe e if ARGV.homebrew_developer? end + @report[:M] << tap.formula_file_to_name(src) + when /^R\d{0,3}/ + @report[:D] << tap.formula_file_to_name(src) if tap.formula_file?(src) + @report[:A] << tap.formula_file_to_name(dst) if tap.formula_file?(dst) end end - map + renamed_formulae = [] + @report[:D].each do |old_full_name| + old_name = old_full_name.split("/").last + new_name = tap.formula_renames[old_name] + next unless new_name + + if tap.core_formula_repository? + new_full_name = new_name + else + new_full_name = "#{tap}/#{new_full_name}" + end + + renamed_formulae << [old_full_name, new_full_name] if @report[:A].include? new_full_name + end + + unless renamed_formulae.empty? + @report[:A] -= renamed_formulae.map(&:last) + @report[:D] -= renamed_formulae.map(&:first) + @report[:R] = renamed_formulae + end + + @report end def updated? - initial_revision && initial_revision != current_revision + initial_revision != current_revision end - private + def migrate_tap_migration + report[:D].each do |full_name| + name = full_name.split("/").last + next unless (dir = HOMEBREW_CELLAR/name).exist? # skip if formula is not installed. + next unless new_tap_name = tap.tap_migrations[name] # skip if formula is not in tap_migrations list. + tabs = dir.subdirs.map { |d| Tab.for_keg(Keg.new(d)) } + next unless tabs.first.tap == tap # skip if installed formula is not from this tap. + new_tap = Tap.fetch(new_tap_name) + new_tap.install unless new_tap.installed? + # update tap for each Tab + tabs.each { |tab| tab.tap = new_tap } + tabs.each(&:write) + end + end - def formula_directory - if repository == HOMEBREW_REPOSITORY - "Library/Formula" - elsif repository.join("Formula").directory? - "Formula" - elsif repository.join("HomebrewFormula").directory? - "HomebrewFormula" - else - "." + def migrate_formula_rename + report[:R].each do |old_full_name, new_full_name| + old_name = old_full_name.split("/").last + next unless (dir = HOMEBREW_CELLAR/old_name).directory? && !dir.subdirs.empty? + + begin + f = Formulary.factory(new_full_name) + rescue Exception => e + onoe e if ARGV.homebrew_developer? + next + end + + begin + migrator = Migrator.new(f) + migrator.migrate + rescue Migrator::MigratorDifferentTapsError + rescue Exception => e + onoe e + end end end - def read_current_revision - `git rev-parse -q --verify HEAD`.chomp + private + + def repo_var + @repo_var ||= if tap.path == HOMEBREW_REPOSITORY + "" + else + tap.path.to_s. + strip_prefix(Tap::TAP_DIRECTORY.to_s). + tr("^A-Za-z0-9", "_"). + upcase + end end def diff Utils.popen_read( - "git", "diff-tree", "-r", "--name-status", "--diff-filter=AMDR", + "git", "-C", tap.path, "diff-tree", "-r", "--name-status", "--diff-filter=AMDR", "-M85%", initial_revision, current_revision ) end - - def `(cmd) - out = super - unless $?.success? - $stderr.puts(out) unless out.empty? - raise ErrorDuringExecution.new(cmd) - end - ohai(cmd, out) if ARGV.verbose? - out - end end class Report
false
Other
Homebrew
brew
842e19bbeb9a595995770f4dba952483c8e4789a.json
README.md: Fix a typo Closes Homebrew/homebrew#49500. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
README.md
@@ -34,7 +34,7 @@ Code is under the [BSD 2 Clause (NetBSD) license](https://github.com/Homebrew/ho Documentation is under the [Creative Commons Attribution license](https://creativecommons.org/licenses/by/4.0/). ## Donations -Homebrew is a non-profit project run entirely by unpaid volunteers. We need your funds to pay for software, hardware and hosting around continous integration and future improvements to the project. Every donation will be spent on making Homebrew better for our users. +Homebrew is a non-profit project run entirely by unpaid volunteers. We need your funds to pay for software, hardware and hosting around continuous integration and future improvements to the project. Every donation will be spent on making Homebrew better for our users. Homebrew is a member of the [Software Freedom Conservancy](http://sfconservancy.org) which provides us with an ability to receive tax-deductible, Homebrew earmarked donations (and [many other services](http://sfconservancy.org/members/services/)). Software Freedom Conservancy, Inc. is a 501(c)(3) organization incorporated in New York, and donations made to it are fully tax-deductible to the extent permitted by law.
false
Other
Homebrew
brew
6ac6cb4fcdc5c162543e14688d41c0b10a1b1e4a.json
TapLoader: improve load logic * Use `Tap#formula_dir` instead of `Tap#formula_files` to find formula file to have better performance and avoid caching issue. * Change the loader logic to search name -> search alias -> search old name. This is more consistence with what we do when loading core formula file. Closes Homebrew/homebrew#49484. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/formulary.rb
@@ -148,15 +148,17 @@ class TapLoader < FormulaLoader def initialize(tapped_name) user, repo, name = tapped_name.split("/", 3).map(&:downcase) @tap = Tap.fetch user, repo - name = @tap.formula_renames.fetch(name, name) - path = @tap.formula_files.detect { |file| file.basename(".rb").to_s == name } + formula_dir = @tap.formula_dir || @tap.path + path = formula_dir/"#{name}.rb" - unless path + unless path.file? if (possible_alias = @tap.alias_dir/name).file? path = possible_alias.resolved_path name = path.basename(".rb").to_s - else - path = @tap.path/"#{name}.rb" + elsif (new_name = @tap.formula_renames[name]) && + (new_path = formula_dir/"#{new_name}.rb").file? + path = new_path + name = new_name end end
false
Other
Homebrew
brew
6b6159a858009b6d82b858830533a4a3ce135a28.json
list: exclude .github from unbrewed Recently added files polluting brew ls --unbrewed results. Closes Homebrew/homebrew#49456. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/cmd/list.rb
@@ -42,6 +42,7 @@ def list UNBREWED_EXCLUDE_FILES = %w[.DS_Store] UNBREWED_EXCLUDE_PATHS = %w[ + .github/* bin/brew lib/gdk-pixbuf-2.0/* lib/gio/*
false
Other
Homebrew
brew
a0855fde264786e5f13169a5e22321793ec1effd.json
README: use secure SFC links
README.md
@@ -56,6 +56,6 @@ Our bottles (binary packages) are hosted by Bintray. [![Downloads by Bintray](https://bintray.com/docs/images/downloads_by_bintray_96.png)](https://bintray.com/homebrew) -Homebrew is a member of the [Software Freedom Conservancy](http://sfconservancy.org) +Homebrew is a member of the [Software Freedom Conservancy](https://sfconservancy.org) -[![Software Freedom Conservancy](http://sfconservancy.org/img/conservancy_64x64.png)](http://sfconservancy.org) +[![Software Freedom Conservancy](https://sfconservancy.org/img/conservancy_64x64.png)](https://sfconservancy.org)
false
Other
Homebrew
brew
e00375e381c7bcd4f0db0d69944dbf831fc62672.json
test_pathname: add append_lines tests Closes Homebrew/homebrew#49233. Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
Library/Homebrew/test/test_pathname.rb
@@ -51,6 +51,18 @@ def test_write_does_not_overwrite assert_raises(RuntimeError) { @file.write("CONTENT") } end + def test_append_lines + touch @file + @file.append_lines("CONTENT") + assert_equal "CONTENT\n", File.read(@file) + @file.append_lines("CONTENTS") + assert_equal "CONTENT\nCONTENTS\n", File.read(@file) + end + + def test_append_lines_does_not_create + assert_raises(RuntimeError) { @file.append_lines("CONTENT") } + end + def test_atomic_write touch @file @file.atomic_write("CONTENT")
false
Other
Homebrew
brew
ff4d16deebaabc374f4dae2786bd01e2865875a4.json
pathname: add append_lines method * Blocks writing of new files via accidental typos, etc, which the normal open("blah", "a") doesn't. * Where files don't exist they should ideally be using `(buildpath/"dog").write` instead of open("blah", "a") already. * It's a bit less cluttered looking if you need several writes to different files in the formula, IMO.
Library/Homebrew/extend/pathname.rb
@@ -131,6 +131,12 @@ def write(content, *open_args) open("w", *open_args) { |f| f.write(content) } end + # Only appends to a file that is already created. + def append_lines(content, *open_args) + raise "Cannot append file that doesn't exist: #{self}" unless exist? + open("a", *open_args) { |f| f.puts(content) } + end + def binwrite(contents, *open_args) open("wb", *open_args) { |f| f.write(contents) } end unless method_defined?(:binwrite)
false
Other
Homebrew
brew
bfbdfe8d9da53209dcc66ee0e9980078669a4acd.json
env/shared: ignore perl opts In theory, letting these be set once wasn't an awful idea because it allows users choice on where Perl modules end up. In reality, as we've moved closer to sandboxing and at the same time accepted more perl binding options into formulae it has been exposed as something of a hellraiser. It's not that uncommon for Perl users to set a custom `INSTALL_BASE` in the ENV which means we end up with quite a few formula that fail hard with this sort of error: ``` Only one of PREFIX or INSTALL_BASE can be given. Not both. ``` The other common error, which we discovered via sandboxing, is that the Perl modules end up outside Homebrew's control which means we don't automatically remove them when the package is removed. Sandboxing blocks this, which means when we eventually move to enable that by default for users as well as CI it'll quickly become a prominent issue.
Library/Homebrew/extend/ENV/shared.rb
@@ -22,7 +22,7 @@ module SharedEnvExtension CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS MACOSX_DEPLOYMENT_TARGET SDKROOT DEVELOPER_DIR CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH - GOBIN GOPATH GOROOT + GOBIN GOPATH GOROOT PERL_MB_OPT PERL_MM_OPT LIBRARY_PATH ]
false
Other
Homebrew
brew
7572e91a6031dfc2c5d12d07686436aa44de501e.json
diagnostic: add new osxfuse exceptions The recent updates to OSXFuse include two new elements that get flagged by `brew doctor`. Adding them here so it's consistent with how we handle the rest of OSXFuse. Closes Homebrew/homebrew#49372.
Library/Homebrew/diagnostic.rb
@@ -175,6 +175,7 @@ def check_for_stray_dylibs "libmacfuse_i64.2.dylib", # OSXFuse MacFuse compatibility layer "libosxfuse_i32.2.dylib", # OSXFuse "libosxfuse_i64.2.dylib", # OSXFuse + "libosxfuse.2.dylib", # OSXFuse "libTrAPI.dylib", # TrAPI / Endpoint Security VPN "libntfs-3g.*.dylib", # NTFS-3G "libntfs.*.dylib", # NTFS-3G @@ -238,6 +239,7 @@ def check_for_stray_las "libfuse_ino64.la", # MacFuse "libosxfuse_i32.la", # OSXFuse "libosxfuse_i64.la", # OSXFuse + "libosxfuse.la", # OSXFuse "libntfs-3g.la", # NTFS-3G "libntfs.la", # NTFS-3G "libublio.la", # NTFS-3G
false
Other
Homebrew
brew
f8a86e596204d7201a2dd9416ada658545f1c30b.json
tests: add groups and project name to coverage Groups make it easier to get an overview of the coverage without having to scan through a single very long list of files. They also display a possibly helpful per-group coverage. The project name is normally derived from the `root` directory which happens to be `Library` in our case, thus make it explicitly `Homebrew`. Closes Homebrew/homebrew#49303. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Library/Homebrew/test/.simplecov
@@ -18,6 +18,19 @@ SimpleCov.start do unless ENV["HOMEBREW_INTEGRATION_TEST"] track_files "#{SimpleCov.root}/**/*.rb" end + + # Add groups and the proper project name to the output. + project_name "Homebrew" + add_group "Commands", %w[/Homebrew/cmd/ /Homebrew/dev-cmd/] + add_group "Extensions", "/Homebrew/extend/" + add_group "OS", "/Homebrew/os/" + add_group "Requirements", "/Homebrew/requirements/" + add_group "Scripts", %w[ + /brew.rb + /Homebrew/build.rb + /Homebrew/postinstall.rb + /Homebrew/test.rb + ] end if ENV["HOMEBREW_INTEGRATION_TEST"]
false
Other
Homebrew
brew
5aa2712694a418e5f4eacacd2752e68799d312cf.json
docs: fix URLs in issue/PR template Sadly, relative URLs don't work in this context.
.github/ISSUE_TEMPLATE.md
@@ -13,7 +13,7 @@ _Please replace this line with a brief summary of your issue **AND** if reportin ### Feature/Formula Requests: -**Please note by far the quickest way to get a new feature or formula into Homebrew is to file a [Pull Request](CONTRIBUTING.md).** +**Please note by far the quickest way to get a new feature or formula into Homebrew is to file a [Pull Request](https://github.com/Homebrew/homebrew/blob/master/.github/CONTRIBUTING.md).** We will consider your request but it may be closed if it's something we're not actively planning to work on.
true
Other
Homebrew
brew
5aa2712694a418e5f4eacacd2752e68799d312cf.json
docs: fix URLs in issue/PR template Sadly, relative URLs don't work in this context.
.github/PULL_REQUEST_TEMPLATE.md
@@ -1,6 +1,6 @@ ### All Submissions: -- [ ] Have you followed the guidelines in our [Contributing](CONTRIBUTING.md) document? +- [ ] Have you followed the guidelines in our [Contributing](https://github.com/Homebrew/homebrew/blob/master/.github/CONTRIBUTING.md) document? ### New Formulae Submissions:
true
Other
Homebrew
brew
3ac1c7b6533dc5cfe4e74155538ded8b2b1ee9ec.json
update: use GitHub API to avoid unneeded fetches. Check to see if `HEAD` is the same as what we have locally. If it is: don't bother to `git fetch`. Closes Homebrew/homebrew#47888. Closes Homebrew/homebrew#49219. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/cmd/update.sh
@@ -334,6 +334,22 @@ EOS UPSTREAM_BRANCH="$(upstream_branch)" # the refspec ensures that the default upstream branch gets updated ( + UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)" + if [[ "$UPSTREAM_REPOSITORY_URL" = "https://github.com/"* ]] + then + UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}" + UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}" + UPSTREAM_BRANCH_LOCAL_SHA="$(git rev-parse "refs/remotes/origin/$UPSTREAM_BRANCH")" + # Only try to `git fetch` when the upstream branch is at a different SHA + # (so the API does not return 304: unmodified). + UPSTREAM_SHA_HTTP_CODE="$(curl --silent '--max-time' 3 \ + --output /dev/null --write-out "%{http_code}" \ + -H "Accept: application/vnd.github.chitauri-preview+sha" \ + -H "If-None-Match: \"$UPSTREAM_BRANCH_LOCAL_SHA\"" \ + "https://api.github.com/repos/$UPSTREAM_REPOSITORY/commits/$UPSTREAM_BRANCH")" + [[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit + fi + git fetch "${QUIET_ARGS[@]}" origin \ "refs/heads/$UPSTREAM_BRANCH:refs/remotes/origin/$UPSTREAM_BRANCH" || \ odie "Fetching $DIR failed!"
false
Other
Homebrew
brew
f2faf49e3f189885c6787f7d4beb680c3a987d4f.json
formula_installer: use new pour_bottle DSL.
Library/Homebrew/formula_installer.rb
@@ -85,7 +85,15 @@ def pour_bottle?(install_bottle_options = { :warn=>false }) return false unless options.empty? return false if formula.bottle_disabled? return true if formula.local_bottle_path - return false unless formula.pour_bottle? + unless formula.pour_bottle? + if install_bottle_options[:warn] && formula.pour_bottle_check_unsatisfied_reason + opoo <<-EOS.undent + Building #{formula.full_name} from source: + #{formula.pour_bottle_check_unsatisfied_reason} + EOS + end + return false + end unless bottle.compatible_cellar? if install_bottle_options[:warn]
false
Other
Homebrew
brew
81c97e1686b64f969b9af71c5142e6fb20d42ee2.json
PULL_REQUEST_TEMPLATE: create initial template
.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,17 @@ +### All Submissions: +- [ ] Have you followed the guidelines in our [Contributing](CONTRIBUTING.md) document? + +### New Formulae Submissions: + +- [ ] Does your submission pass: +`brew audit --strict --online <formula>` (where `<formula>` is the name of the formula you're submitting). +- [ ] Have you built your formula locally prior to submission with `brew install <formula>`? + +### Formulae Updates/Changes: + +- [ ] If your changes include a new `patch` have you submitted the patch upstream & included a brief explanation/link to the upstream submission in the formula? + +### Changes to Homebrew's Core: +- [ ] Have you added an explanation of what your changes do and why you'd like us to include them? +- [ ] Have you written new tests for your core changes, as applicable? [Here's an example](https://github.com/Homebrew/homebrew/pull/49031) if you'd like one. +- [ ] Have you successfully ran `brew tests` with your changes locally?
false
Other
Homebrew
brew
a049aaa84c311014cd16b264491f7f3d8fcd7999.json
docs: move security reporting guidelines
.github/CONTRIBUTING.md
@@ -34,8 +34,4 @@ First time contributing to Homebrew? Read our [Code of Conduct](https://github.c * `git commit` with message formatted `foo: fix <insert details>` * [open a pull request](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md#how-to-open-a-homebrew-pull-request-and-get-it-merged) and fix any failing tests -### Report a security vulnerability - -* [Email security@brew.sh](mailto:security@brew.sh) (a private mailing list) with detailed reproduction instructions using [our PGP key](https://keybase.io/homebrew/key.asc) - Thanks!
true
Other
Homebrew
brew
a049aaa84c311014cd16b264491f7f3d8fcd7999.json
docs: move security reporting guidelines
.github/ISSUE_TEMPLATE.md
@@ -16,3 +16,7 @@ _Please replace this line with a brief summary of your issue **AND** if reportin **Please note by far the quickest way to get a new feature or formula into Homebrew is to file a [Pull Request](CONTRIBUTING.md).** We will consider your request but it may be closed if it's something we're not actively planning to work on. + +### Report a security vulnerability + +* [Email security@brew.sh](mailto:security@brew.sh) (a private mailing list) with detailed reproduction instructions optionally using [our PGP key](https://keybase.io/homebrew/key.asc)
true
Other
Homebrew
brew
bcc5591702968d011af61586a3917413455b0981.json
ISSUE_TEMPLATE: create initial template Closes Homebrew/homebrew#41321.
.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,18 @@ +# Please follow the general troubleshooting steps first: + +- [ ] Ran `brew update` and retried your prior step? +- [ ] Ran `brew doctor`, fixed as many issues as possible and retried your prior step? +- [ ] If you're seeing permission errors tried running `sudo chown -R $(whoami) $(brew --prefix)`? + +### Bug reports: + +_Please replace this line with a brief summary of your issue **AND** if reporting a build issue underneath include the link from:_ + +`brew gist-logs <formula>` +(where `<formula>` is the name of the formula that failed to build). + +### Feature/Formula Requests: + +**Please note by far the quickest way to get a new feature or formula into Homebrew is to file a [Pull Request](CONTRIBUTING.md).** + +We will consider your request but it may be closed if it's something we're not actively planning to work on.
false
Other
Homebrew
brew
ee9b6572132f7e7f1ee34c05afae6e7bb2e49614.json
gitignore: update documentation paths
.gitignore
@@ -30,6 +30,7 @@ /share/doc # Unignore our documentation. +!/.github !/share/doc/homebrew !/share/man/man1/brew.1 @@ -38,7 +39,6 @@ !/.travis.yml !/.yardopts !/CODEOFCONDUCT.md -!/CONTRIBUTING.md !/LICENSE.txt !/README.md !/SUPPORTERS.md
false
Other
Homebrew
brew
4a289a65d4a1c91c849a24533e56a3f612a6b01b.json
Troubleshooting: remove dead link
share/doc/homebrew/Troubleshooting.md
@@ -14,7 +14,6 @@ brew gist-logs <formula> * If you’re installing something Java-related, maybe you need to install Java (`brew cask install java`)? * Check that **Command Line Tools for Xcode (CLT)** and/or **Xcode** are up to date. * If things fail with permissions errors, check the permissions in `/usr/local`. If you’re unsure what to do, you can `sudo chown -R $(whoami) /usr/local`. -* If you see permission errors after upgrading to El Capitan please see the [El Capitan and Homebrew](El_Capitan_and_Homebrew.md) document. ## Check to see if the issue has been reported * Check the [issue tracker](https://github.com/Homebrew/homebrew/issues) to see if someone else has already reported the same issue.
false
Other
Homebrew
brew
691e4aec11a71bdd88a59391aa7b56ea0cf48639.json
bin/brew: move logic to Library. `bin/brew` is getting a bit bloated and it's annoying to open all of `HOMEBREW_PREFIX` in your editor of choice and have it search through the `Cellar`. Let's instead keep the bare minimum in `bin/brew` and move the rest to `Library`. Closes Homebrew/homebrew#49185. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/brew.sh
@@ -0,0 +1,172 @@ +odie() { + if [[ -t 2 ]] # check whether stderr is a tty. + then + echo -ne "\033[4;31mError\033[0m: " >&2 # highlight Error with underline and red color + else + echo -n "Error: " >&2 + fi + if [[ $# -eq 0 ]] + then + /bin/cat >&2 + else + echo "$*" >&2 + fi + exit 1 +} + +chdir() { + cd "$@" >/dev/null || odie "Error: failed to cd to $*!" +} + +# Force UTF-8 to avoid encoding issues for users with broken locale settings. +if [[ "$(locale charmap 2> /dev/null)" != "UTF-8" ]] +then + export LC_ALL="en_US.UTF-8" +fi + +# Where we store built products; /usr/local/Cellar if it exists, +# otherwise a Cellar relative to the Repository. +if [[ -d "$HOMEBREW_PREFIX/Cellar" ]] +then + HOMEBREW_CELLAR="$HOMEBREW_PREFIX/Cellar" +else + HOMEBREW_CELLAR="$HOMEBREW_REPOSITORY/Cellar" +fi + +case "$*" in + --prefix) echo "$HOMEBREW_PREFIX"; exit 0 ;; + --cellar) echo "$HOMEBREW_CELLAR"; exit 0 ;; + --repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;; +esac + +if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]] +then + # it may work, but I only see pain this route and don't want to support it + odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX" +fi + +# Users may have these set, pointing the system Ruby +# at non-system gem paths +unset GEM_HOME +unset GEM_PATH + +if [[ -z "$HOMEBREW_DEVELOPER" ]] +then + unset HOMEBREW_RUBY_PATH +fi + +if [[ "$(uname -s)" = "Darwin" ]] +then + HOMEBREW_OSX="1" +fi + +if [[ -z "$HOMEBREW_RUBY_PATH" ]] +then + if [[ -n "$HOMEBREW_OSX" ]] + then + HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby" + else + HOMEBREW_RUBY_PATH="$(which ruby)" + fi +fi + +export HOMEBREW_BREW_FILE +export HOMEBREW_RUBY_PATH +export HOMEBREW_PREFIX +export HOMEBREW_REPOSITORY +export HOMEBREW_LIBRARY +export HOMEBREW_CELLAR + +if [[ -n "$HOMEBREW_OSX" ]] +then + if [[ "$('/usr/bin/xcode-select' --print-path)" = "/" ]] + then + odie <<EOS +Your xcode-select path is currently set to '/'. +This causes the 'xcrun' tool to hang, and can render Homebrew unusable. +If you are using Xcode, you should: + sudo xcode-select -switch /Applications/Xcode.app +Otherwise, you should: + sudo rm -rf /usr/share/xcode-select +EOS + fi + + XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)" + XCRUN_STATUS="$?" + + if [[ "$XCRUN_STATUS" -ne 0 && "$XCRUN_OUTPUT" = *license* ]] + then + odie <<EOS +You have not agreed to the Xcode license. Please resolve this by running: + sudo xcodebuild -license +EOS + fi +fi + +# Many Pathname operations use getwd when they shouldn't, and then throw +# odd exceptions. Reduce our support burden by showing a user-friendly error. +if [[ ! -d "$(pwd)" ]] +then + odie "The current working directory doesn't exist, cannot proceed." +fi + +if [[ "$1" = -v ]] +then + # Shift the -v to the end of the parameter list + shift + set -- "$@" -v +fi + +HOMEBREW_COMMAND="$1" +shift +case "$HOMEBREW_COMMAND" in + ls) HOMEBREW_COMMAND="list";; + homepage) HOMEBREW_COMMAND="home";; + -S) HOMEBREW_COMMAND="search";; + up) HOMEBREW_COMMAND="update";; + ln) HOMEBREW_COMMAND="link";; + instal) HOMEBREW_COMMAND="install";; # gem does the same + rm) HOMEBREW_COMMAND="uninstall";; + remove) HOMEBREW_COMMAND="uninstall";; + configure) HOMEBREW_COMMAND="diy";; + abv) HOMEBREW_COMMAND="info";; + dr) HOMEBREW_COMMAND="doctor";; + --repo) HOMEBREW_COMMAND="--repository";; + environment) HOMEBREW_COMMAND="--env";; + --config) HOMEBREW_COMMAND="config";; +esac + +if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] ; then + HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" +elif [[ -n "$HOMEBREW_DEVELOPER" && -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]] ; then + HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" +fi + +if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] +then + case "$HOMEBREW_COMMAND" in + install|reinstall|postinstall|link|pin|update|update-ruby|upgrade|create|migrate|tap|switch) + odie <<EOS +Cowardly refusing to 'sudo brew $HOMEBREW_COMMAND' +You can use brew with sudo, but only if the brew executable is owned by root. +However, this is both not recommended and completely unsupported so do so at +your own risk. +EOS + ;; + esac +fi + +if [[ -n "$HOMEBREW_BASH_COMMAND" ]] +then + # source rather than executing directly to ensure the entire file is read into + # memory before it is run. This makes running a Bash script behave more like + # a Ruby script and avoids hard-to-debug issues if the Bash script is updated + # at the same time as being run. + # + # Hide shellcheck complaint: + # shellcheck source=/dev/null + source "$HOMEBREW_BASH_COMMAND" + { "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; } +else + exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$HOMEBREW_COMMAND" "$@" +fi
true
Other
Homebrew
brew
691e4aec11a71bdd88a59391aa7b56ea0cf48639.json
bin/brew: move logic to Library. `bin/brew` is getting a bit bloated and it's annoying to open all of `HOMEBREW_PREFIX` in your editor of choice and have it search through the `Cellar`. Let's instead keep the bare minimum in `bin/brew` and move the rest to `Library`. Closes Homebrew/homebrew#49185. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
bin/brew
@@ -1,31 +1,8 @@ #!/bin/bash - -odie() { - if [[ -t 2 ]] # check whether stderr is a tty. - then - echo -ne "\033[4;31mError\033[0m: " >&2 # highlight Error with underline and red color - else - echo -n "Error: " >&2 - fi - if [[ $# -eq 0 ]] - then - /bin/cat >&2 - else - echo "$*" >&2 - fi - exit 1 -} - chdir() { - cd "$@" >/dev/null || odie "Error: failed to cd to $*!" + cd "$@" >/dev/null } -# Force UTF-8 to avoid encoding issues for users with broken locale settings. -if [[ "$(locale charmap 2> /dev/null)" != "UTF-8" ]] -then - export LC_ALL="en_US.UTF-8" -fi - BREW_FILE_DIRECTORY="$(chdir "${0%/*}" && pwd -P)" HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/${0##*/}" @@ -41,149 +18,4 @@ HOMEBREW_PREFIX="$(chdir "$(dirname "$(dirname "$HOMEBREW_BREW_FILE")")" && pwd HOMEBREW_REPOSITORY="$(chdir "$BREW_FILE_DIRECTORY"/../ && pwd -P)" HOMEBREW_LIBRARY="$(chdir "$BREW_FILE_DIRECTORY"/../Library && pwd -P)" -# Where we store built products; /usr/local/Cellar if it exists, -# otherwise a Cellar relative to the Repository. -if [[ -d "$HOMEBREW_PREFIX/Cellar" ]] -then - HOMEBREW_CELLAR="$HOMEBREW_PREFIX/Cellar" -else - HOMEBREW_CELLAR="$HOMEBREW_REPOSITORY/Cellar" -fi - -case "$*" in - --prefix) echo "$HOMEBREW_PREFIX"; exit 0 ;; - --cellar) echo "$HOMEBREW_CELLAR"; exit 0 ;; - --repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;; -esac - -if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]] -then - # it may work, but I only see pain this route and don't want to support it - odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX" -fi - -# Users may have these set, pointing the system Ruby -# at non-system gem paths -unset GEM_HOME -unset GEM_PATH - -if [[ -z "$HOMEBREW_DEVELOPER" ]] -then - unset HOMEBREW_RUBY_PATH -fi - -if [[ "$(uname -s)" = "Darwin" ]] -then - HOMEBREW_OSX="1" -fi - -if [[ -z "$HOMEBREW_RUBY_PATH" ]] -then - if [[ -n "$HOMEBREW_OSX" ]] - then - HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby" - else - HOMEBREW_RUBY_PATH="$(which ruby)" - fi -fi - -export HOMEBREW_BREW_FILE -export HOMEBREW_RUBY_PATH -export HOMEBREW_PREFIX -export HOMEBREW_REPOSITORY -export HOMEBREW_LIBRARY -export HOMEBREW_CELLAR - -if [[ -n "$HOMEBREW_OSX" ]] -then - if [[ "$('/usr/bin/xcode-select' --print-path)" = "/" ]] - then - odie <<EOS -Your xcode-select path is currently set to '/'. -This causes the 'xcrun' tool to hang, and can render Homebrew unusable. -If you are using Xcode, you should: - sudo xcode-select -switch /Applications/Xcode.app -Otherwise, you should: - sudo rm -rf /usr/share/xcode-select -EOS - fi - - XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)" - XCRUN_STATUS="$?" - - if [[ "$XCRUN_STATUS" -ne 0 && "$XCRUN_OUTPUT" = *license* ]] - then - odie <<EOS -You have not agreed to the Xcode license. Please resolve this by running: - sudo xcodebuild -license -EOS - fi -fi - -# Many Pathname operations use getwd when they shouldn't, and then throw -# odd exceptions. Reduce our support burden by showing a user-friendly error. -if [[ ! -d "$(pwd)" ]] -then - odie "The current working directory doesn't exist, cannot proceed." -fi - -if [[ "$1" = -v ]] -then - # Shift the -v to the end of the parameter list - shift - set -- "$@" -v -fi - -HOMEBREW_COMMAND="$1" -shift -case "$HOMEBREW_COMMAND" in - ls) HOMEBREW_COMMAND="list";; - homepage) HOMEBREW_COMMAND="home";; - -S) HOMEBREW_COMMAND="search";; - up) HOMEBREW_COMMAND="update";; - ln) HOMEBREW_COMMAND="link";; - instal) HOMEBREW_COMMAND="install";; # gem does the same - rm) HOMEBREW_COMMAND="uninstall";; - remove) HOMEBREW_COMMAND="uninstall";; - configure) HOMEBREW_COMMAND="diy";; - abv) HOMEBREW_COMMAND="info";; - dr) HOMEBREW_COMMAND="doctor";; - --repo) HOMEBREW_COMMAND="--repository";; - environment) HOMEBREW_COMMAND="--env";; - --config) HOMEBREW_COMMAND="config";; -esac - -if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] ; then - HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" -elif [[ -n "$HOMEBREW_DEVELOPER" && -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]] ; then - HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" -fi - -if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] -then - case "$HOMEBREW_COMMAND" in - install|reinstall|postinstall|link|pin|update|update-ruby|upgrade|create|migrate|tap|switch) - odie <<EOS -Cowardly refusing to 'sudo brew $HOMEBREW_COMMAND' -You can use brew with sudo, but only if the brew executable is owned by root. -However, this is both not recommended and completely unsupported so do so at -your own risk. -EOS - ;; - esac -fi - -if [[ -n "$HOMEBREW_BASH_COMMAND" ]] -then - # source rather than executing directly to ensure the entire file is read into - # memory before it is run. This makes running a Bash script behave more like - # a Ruby script and avoids hard-to-debug issues if the Bash script is updated - # at the same time as being run. - # - # Hide shellcheck complaint: - # shellcheck source=/dev/null - source "$HOMEBREW_BASH_COMMAND" - { "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; } -else - exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$HOMEBREW_COMMAND" "$@" -fi +source "$HOMEBREW_LIBRARY/brew.sh"
true
Other
Homebrew
brew
f6cbf7bab0a4d743ca4122c39d60ea669b5f7e14.json
Move internal command aliases from Ruby to Bash. This means that internal command aliases can be used for Bash commands (such as the new, Bash-based `brew update`). Fixes Homebrew/homebrew#49182. Closes Homebrew/homebrew#49184. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/global.rb
@@ -48,6 +48,7 @@ module Homebrew ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map { |p| Pathname.new(p).expand_path rescue nil }.compact.freeze +# TODO: remove this as soon as it's removed from commands.rb. HOMEBREW_INTERNAL_COMMAND_ALIASES = { "ls" => "list", "homepage" => "home",
true
Other
Homebrew
brew
f6cbf7bab0a4d743ca4122c39d60ea669b5f7e14.json
Move internal command aliases from Ruby to Bash. This means that internal command aliases can be used for Bash commands (such as the new, Bash-based `brew update`). Fixes Homebrew/homebrew#49182. Closes Homebrew/homebrew#49184. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/brew.rb
@@ -44,8 +44,6 @@ def require?(path) end end - cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) - # Add contributed commands to PATH before checking. Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/cmd"].each do |tap_cmd_dir| ENV["PATH"] += "#{File::PATH_SEPARATOR}#{tap_cmd_dir}"
true
Other
Homebrew
brew
f6cbf7bab0a4d743ca4122c39d60ea669b5f7e14.json
Move internal command aliases from Ruby to Bash. This means that internal command aliases can be used for Bash commands (such as the new, Bash-based `brew update`). Fixes Homebrew/homebrew#49182. Closes Homebrew/homebrew#49184. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
bin/brew
@@ -135,6 +135,24 @@ then fi HOMEBREW_COMMAND="$1" +shift +case "$HOMEBREW_COMMAND" in + ls) HOMEBREW_COMMAND="list";; + homepage) HOMEBREW_COMMAND="home";; + -S) HOMEBREW_COMMAND="search";; + up) HOMEBREW_COMMAND="update";; + ln) HOMEBREW_COMMAND="link";; + instal) HOMEBREW_COMMAND="install";; # gem does the same + rm) HOMEBREW_COMMAND="uninstall";; + remove) HOMEBREW_COMMAND="uninstall";; + configure) HOMEBREW_COMMAND="diy";; + abv) HOMEBREW_COMMAND="info";; + dr) HOMEBREW_COMMAND="doctor";; + --repo) HOMEBREW_COMMAND="--repository";; + environment) HOMEBREW_COMMAND="--env";; + --config) HOMEBREW_COMMAND="config";; +esac + if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]] ; then HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" elif [[ -n "$HOMEBREW_DEVELOPER" && -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]] ; then @@ -144,7 +162,7 @@ fi if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] then case "$HOMEBREW_COMMAND" in - instal|install|reinstall|postinstall|ln|link|pin|update|update-ruby|upgrade|create|migrate|tap|switch) + install|reinstall|postinstall|ln|link|pin|update|update-ruby|upgrade|create|migrate|tap|switch) odie <<EOS Cowardly refusing to 'sudo brew $HOMEBREW_COMMAND' You can use brew with sudo, but only if the brew executable is owned by root. @@ -157,9 +175,6 @@ fi if [[ -n "$HOMEBREW_BASH_COMMAND" ]] then - # Bash commands don't need the first argument, which is just the command name. - shift - # source rather than executing directly to ensure the entire file is read into # memory before it is run. This makes running a Bash script behave more like # a Ruby script and avoids hard-to-debug issues if the Bash script is updated @@ -170,5 +185,5 @@ then source "$HOMEBREW_BASH_COMMAND" { "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; } else - exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$@" + exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$HOMEBREW_COMMAND" "$@" fi
true
Other
Homebrew
brew
775c4eedd7f6342ccfe7fe802a5935cb78ab050d.json
Promote update-bash to the default updater. Also, rename the existing updater to `update-ruby` to allow using as a fallback. It will eventually be removed. Closes Homebrew/homebrew#49109. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/cmd/update-ruby.rb
@@ -6,7 +6,7 @@ require "descriptions" module Homebrew - def update + def update_ruby unless ARGV.named.empty? abort <<-EOS.undent This command updates brew itself, and does not take formula names.
true
Other
Homebrew
brew
775c4eedd7f6342ccfe7fe802a5935cb78ab050d.json
Promote update-bash to the default updater. Also, rename the existing updater to `update-ruby` to allow using as a fallback. It will eventually be removed. Closes Homebrew/homebrew#49109. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/cmd/update.sh
@@ -250,7 +250,7 @@ pull() { trap - SIGINT } -homebrew-update-bash() { +homebrew-update() { local option local DIR local UPSTREAM_BRANCH
true
Other
Homebrew
brew
775c4eedd7f6342ccfe7fe802a5935cb78ab050d.json
Promote update-bash to the default updater. Also, rename the existing updater to `update-ruby` to allow using as a fallback. It will eventually be removed. Closes Homebrew/homebrew#49109. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/test/test_updater.rb
@@ -1,5 +1,5 @@ require "testing_env" -require "cmd/update" +require "cmd/update-ruby" require "formula_versions" require "yaml"
true
Other
Homebrew
brew
775c4eedd7f6342ccfe7fe802a5935cb78ab050d.json
Promote update-bash to the default updater. Also, rename the existing updater to `update-ruby` to allow using as a fallback. It will eventually be removed. Closes Homebrew/homebrew#49109. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
bin/brew
@@ -144,7 +144,7 @@ fi if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] then case "$HOMEBREW_COMMAND" in - instal|install|reinstall|postinstall|ln|link|pin|update|update-bash|upgrade|create|migrate|tap|switch) + instal|install|reinstall|postinstall|ln|link|pin|update|update-ruby|upgrade|create|migrate|tap|switch) odie <<EOS Cowardly refusing to 'sudo brew $HOMEBREW_COMMAND' You can use brew with sudo, but only if the brew executable is owned by root.
true
Other
Homebrew
brew
b389953f5b1b0ec98c069f155c280d60b94eeafb.json
style: update rubocop to 0.37.2 Closes Homebrew/homebrew#49084. Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
Library/Homebrew/cmd/style.rb
@@ -8,7 +8,7 @@ def style ARGV.formulae.map(&:path) end - Homebrew.install_gem_setup_path! "rubocop", "0.36.0" + Homebrew.install_gem_setup_path! "rubocop", "0.37.2" args = [ "--format", "simple", "--force-exclusion", "--config",
false
Other
Homebrew
brew
0322d9bd82c2663daf89b28dec32378eea3fb90c.json
pull --bump: add auto-detection of devel bumps Closes Homebrew/homebrew#48472. Signed-off-by: Andrew Janke <andrew@apjanke.net>
Library/Homebrew/cmd/pull.rb
@@ -1,57 +1,41 @@ # Gets a patch from a GitHub commit or pull request and applies it to Homebrew. -# Optionally, installs it too. +# Optionally, installs the formulae changed by the patch. +# +# Usage: brew pull [options...] <patch-source> +# +# <patch-source> may be any of: +# * The ID number of a pull request in the Homebrew GitHub repo +# * The URL of a pull request on GitHub, using either the web page or API URL formats +# * The URL of a commit on GitHub +# * A "brew.sh/job/..." string specifying a testing job ID +# +# Options: +# --bottle: Handle bottles, pulling the bottle-update commit and publishing files on Bintray +# --bump: For one-formula PRs, automatically reword commit message to our preferred format +# --clean: Do not rewrite or otherwise modify the commits found in the pulled PR +# --ignore-whitespace: Silently ignore whitespace discrepancies when applying diffs +# --install: Install changed formulae locally after pulling the patch +# --resolve: When a patch fails to apply, leave in progress and allow user to +# resolve, instead of aborting +# --branch-okay: Do not warn if pulling to a branch besides master (useful for testing) require "utils" +require "utils/json" require "formula" require "tap" require "core_formula_repository" module Homebrew - def pull_url(url) - # GitHub provides commits/pull-requests raw patches using this URL. - url += ".patch" - - patchpath = HOMEBREW_CACHE + File.basename(url) - curl url, "-o", patchpath - - ohai "Applying patch" - patch_args = [] - # Normally we don't want whitespace errors, but squashing them can break - # patches so an option is provided to skip this step. - if ARGV.include?("--ignore-whitespace") || ARGV.include?("--clean") - patch_args << "--whitespace=nowarn" - else - patch_args << "--whitespace=fix" - end - - # Fall back to three-way merge if patch does not apply cleanly - patch_args << "-3" - patch_args << patchpath - - begin - safe_system "git", "am", *patch_args - rescue ErrorDuringExecution - if ARGV.include? "--resolve" - odie "Patch failed to apply: try to resolve it." - else - system "git", "am", "--abort" - odie "Patch failed to apply: aborted." - end - ensure - patchpath.unlink - end - end - def pull - if ARGV.empty? - odie "This command requires at least one argument containing a URL or pull request number" - end - if ARGV[0] == "--rebase" odie "You meant `git pull --rebase`." end + if ARGV.named.empty? + odie "This command requires at least one argument containing a URL or pull request number" + end + do_bump = ARGV.include?("--bump") && !ARGV.include?("--clean") - bintray_fetch_formulae =[] + bintray_fetch_formulae = [] ARGV.named.each do |arg| if arg.to_i > 0 @@ -88,11 +72,25 @@ def pull revision = `git rev-parse --short HEAD`.strip branch = `git symbolic-ref --short HEAD`.strip - unless branch == "master" - opoo "Current branch is #{branch}: do you need to pull inside master?" unless ARGV.include? "--clean" + unless branch == "master" || ARGV.include?("--clean") || ARGV.include?("--branch-okay") + opoo "Current branch is #{branch}: do you need to pull inside master?" end - pull_url url + patch_puller = PatchPuller.new(url) + patch_puller.fetch_patch + patch_changes = files_changed_in_patch(patch_puller.patchpath, tap) + is_bumpable = patch_changes[:formulae].length == 1 && patch_changes[:others].empty? + if do_bump + odie "No changed formulae found to bump" if patch_changes[:formulae].empty? + if patch_changes[:formulae].length > 1 + odie "Can only bump one changed formula; bumped #{patch_changes[:formulae]}" + end + odie "Can not bump if non-formula files are changed" unless patch_changes[:others].empty? + end + if is_bumpable + old_versions = current_versions_from_info_external(patch_changes[:formulae].first) + end + patch_puller.apply_patch changed_formulae = [] @@ -101,7 +99,6 @@ def pull "--diff-filter=AM", revision, "HEAD", "--", tap.formula_dir.to_s ).each_line do |line| name = "#{tap.name}/#{File.basename(line.chomp, ".rb")}" - begin changed_formulae << Formula[name] # Make sure we catch syntax errors. @@ -126,26 +123,44 @@ def pull end end + orig_message = message = `git log HEAD^.. --format=%B` if issue && !ARGV.include?("--clean") ohai "Patch closes issue ##{issue}" - message = `git log HEAD^.. --format=%B` - - if ARGV.include? "--bump" - odie "Can only bump one changed formula" unless changed_formulae.length == 1 - formula = changed_formulae.first - subject = "#{formula.name} #{formula.version}" - ohai "New bump commit subject: #{subject}" - system "/bin/echo -n #{subject} | pbcopy" - message = "#{subject}\n\n#{message}" - end - # If this is a pull request, append a close message. unless message.include? "Closes ##{issue}." message += "\nCloses ##{issue}." - safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message end end + if changed_formulae.empty? + odie "cannot bump: no changed formulae found after applying patch" if do_bump + is_bumpable = false + end + if is_bumpable && !ARGV.include?("--clean") + formula = changed_formulae.first + new_versions = { + :stable => formula.stable.nil? ? nil : formula.stable.version.to_s, + :devel => formula.devel.nil? ? nil : formula.devel.version.to_s, + } + orig_subject = message.empty? ? "" : message.lines.first.chomp + subject = subject_for_bump(formula, old_versions, new_versions) + if do_bump + odie "No version changes found for #{formula.name}" if subject.nil? + unless orig_subject == subject + ohai "New bump commit subject: #{subject}" + pbcopy subject + message = "#{subject}\n\n#{message}" + end + elsif subject != orig_subject && !subject.nil? + opoo "Nonstandard bump subject: #{orig_subject}" + opoo "Subject should be: #{subject}" + end + end + + if message != orig_message && !ARGV.include?("--clean") + safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message + end + if fetch_bottles bottle_commit_url = if testing_job bottle_branch = "testing-bottle-#{testing_job}" @@ -161,7 +176,7 @@ def pull curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url safe_system "git", "checkout", "-B", bottle_branch, revision - pull_url bottle_commit_url + pull_patch bottle_commit_url safe_system "git", "rebase", branch safe_system "git", "checkout", branch safe_system "git", "merge", "--ff-only", "--no-edit", bottle_branch @@ -217,4 +232,140 @@ def pull end end end + + private + + def pull_patch(url) + PatchPuller.new(url).pull_patch + end + + class PatchPuller + attr_reader :base_url + attr_reader :patch_url + attr_reader :patchpath + + def initialize(url) + @base_url = url + # GitHub provides commits/pull-requests raw patches using this URL. + @patch_url = url + ".patch" + @patchpath = HOMEBREW_CACHE + File.basename(patch_url) + end + + def pull_patch + fetch_patch + apply_patch + end + + def fetch_patch + ohai "Fetching patch" + curl patch_url, "-o", patchpath + end + + def apply_patch + # Applies a patch previously downloaded with fetch_patch() + # Deletes the patch file as a side effect, regardless of success + + ohai "Applying patch" + patch_args = [] + # Normally we don't want whitespace errors, but squashing them can break + # patches so an option is provided to skip this step. + if ARGV.include?("--ignore-whitespace") || ARGV.include?("--clean") + patch_args << "--whitespace=nowarn" + else + patch_args << "--whitespace=fix" + end + + # Fall back to three-way merge if patch does not apply cleanly + patch_args << "-3" + patch_args << patchpath + + begin + safe_system "git", "am", *patch_args + rescue ErrorDuringExecution + if ARGV.include? "--resolve" + odie "Patch failed to apply: try to resolve it." + else + system "git", "am", "--abort" + odie "Patch failed to apply: aborted." + end + ensure + patchpath.unlink + end + end + end + + # List files changed by a patch, partitioned in to those that are (probably) + # formula definitions, and those which aren't. Only applies to patches on + # Homebrew core or taps, based simply on relative pathnames of affected files. + def files_changed_in_patch(patchfile, tap) + files = [] + formulae = [] + others = [] + File.foreach(patchfile) do |line| + files << $1 if line =~ %r{^\+\+\+ b/(.*)} + end + files.each do |file| + if (tap.path/file).dirname == tap.formula_dir + formula_name = File.basename(file, ".rb") + formulae << formula_name unless formulae.include?(formula_name) + else + others << file + end + end + { :files => files, :formulae => formulae, :others => others } + end + + # Get current formula versions without loading formula definition in this process + # Returns info as a hash (type => version), for pull.rb's internal use + # Uses special key :nonexistent => true for nonexistent formulae + def current_versions_from_info_external(formula_name) + versions = {} + json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", formula_name) + if $?.success? + info = Utils::JSON.load(json) + [:stable, :devel, :head].each do |vertype| + versions[vertype] = info[0]["versions"][vertype.to_s] + end + else + versions[:nonexistent] = true + end + versions + end + + def subject_for_bump(formula, old, new) + if old[:nonexistent] + # New formula + headline_ver = new[:stable] ? new[:stable] : new[:devel] ? new[:devel] : new[:head] + subject = "#{formula.name} #{headline_ver} (new formula)" + else + # Update to existing formula + subject_strs = [] + formula_name_str = formula.name + if old[:stable] != new[:stable] + if new[:stable].nil? + subject_strs << "remove stable" + formula_name_str += ":" # just for cosmetics + else + subject_strs << formula.version.to_s + end + end + if old[:devel] != new[:devel] + if new[:devel].nil? + # Only bother mentioning if there's no accompanying stable change + if !new[:stable].nil? && old[:stable] == new[:stable] + subject_strs << "remove devel" + formula_name_str += ":" # just for cosmetics + end + else + subject_strs << "#{formula.devel.version} (devel)" + end + end + subject = subject_strs.empty? ? nil : "#{formula_name_str} #{subject_strs.join(", ")}" + end + subject + end + + def pbcopy(text) + Utils.popen_write("pbcopy") { |io| io.write text } + end end
false
Other
Homebrew
brew
0386f332229d0a6ca28813d84fc0eb480cd36310.json
tests: Add missing version tests Closes Homebrew/homebrew#49031. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/test/test_versions.rb
@@ -12,6 +12,32 @@ def test_raises_for_non_string_objects assert_raises(TypeError) { Version.new(1) } assert_raises(TypeError) { Version.new(:symbol) } end + + def test_detected_from_url? + refute Version.new("1.0").detected_from_url? + assert Version::FromURL.new("1.0").detected_from_url? + end +end + +class VersionTokenTests < Homebrew::TestCase + def test_inspect + assert_equal '#<Version::Token "foo">', + Version::Token.new("foo").inspect + end + + def test_to_s + assert_equal "foo", Version::Token.new("foo").to_s + end +end + +class VersionNullTokenTests < Homebrew::TestCase + def test_inspect + assert_equal "#<Version::NullToken>", Version::NullToken.new.inspect + end + + def test_comparing_null + assert_operator Version::NullToken.new, :==, Version::NullToken.new + end end class VersionComparisonTests < Homebrew::TestCase @@ -404,4 +430,9 @@ def test_waf_version def test_dash_separated_version assert_version_detected "6-20151227", "ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2" end + + def test_from_url + assert_version_detected "1.2.3", + "http://github.com/foo/bar.git", {:tag => "v1.2.3"} + end end
true
Other
Homebrew
brew
0386f332229d0a6ca28813d84fc0eb480cd36310.json
tests: Add missing version tests Closes Homebrew/homebrew#49031. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/test/testing_env.rb
@@ -30,8 +30,8 @@ def assert_version_equal(expected, actual) assert_equal Version.new(expected), actual end - def assert_version_detected(expected, url) - assert_equal expected, Version.parse(url).to_s + def assert_version_detected(expected, url, specs={}) + assert_equal expected, Version.detect(url, specs).to_s end def assert_version_nil(url)
true
Other
Homebrew
brew
e84539135969e84a1b451f524a43f58ff42b6d37.json
os/mac: add Xcode 7.2.1
Library/Homebrew/os/mac.rb
@@ -270,6 +270,7 @@ def preferred_arch "7.1" => { :clang => "7.0", :clang_build => 700 }, "7.1.1" => { :clang => "7.0", :clang_build => 700 }, "7.2" => { :clang => "7.0", :clang_build => 700 }, + "7.2.1" => { :clang => "7.0", :clang_build => 700 }, } def compilers_standard?
false
Other
Homebrew
brew
eba429d947a59ab4d80ccac0cffbe34b3c75c48d.json
tests: add leaves & prune integration tests Closes Homebrew/homebrew#48943. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/test/test_integration_cmds.rb
@@ -639,6 +639,56 @@ def test_log (HOMEBREW_REPOSITORY/".git").rmtree end + def test_leaves + formula_dir = CoreFormulaRepository.new.formula_dir + formula_file1 = formula_dir/"testball1.rb" + formula_file2 = formula_dir/"testball2.rb" + formula_file1.write <<-EOS.undent + class Testball1 < Formula + url "https://example.com/testball1-0.1.tar.gz" + end + EOS + formula_file2.write <<-EOS.undent + class Testball2 < Formula + url "https://example.com/testball2-0.1.tar.gz" + depends_on "testball1" + end + EOS + assert_equal "", cmd("leaves") + + (HOMEBREW_CELLAR/"testball1/0.1/somedir").mkpath + assert_equal "testball1", cmd("leaves") + + (HOMEBREW_CELLAR/"testball2/0.1/somedir").mkpath + assert_equal "testball2", cmd("leaves") + ensure + (HOMEBREW_CELLAR/"testball1").rmtree + (HOMEBREW_CELLAR/"testball2").rmtree + formula_file1.unlink + formula_file2.unlink + end + + def test_prune + share = (HOMEBREW_PREFIX/"share") + + (share/"pruneable/directory/here").mkpath + (share/"notpruneable/file").write "I'm here" + FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink" + + assert_match %r{Would remove \(empty directory\): .*/pruneable/directory/here}, + cmd("prune", "--dry-run") + assert_match "Pruned 1 symbolic links and 3 directories", + cmd("prune") + refute (share/"pruneable").directory? + assert (share/"notpruneable").directory? + refute (share/"pruneable_symlink").symlink? + + assert_equal "Nothing pruned", + cmd("prune", "--verbose") + ensure + share.rmtree + end + def test_custom_command mktmpdir do |path| cmd = "int-test-#{rand}"
false
Other
Homebrew
brew
4ce99fa0102c352f79071d8ae6aa64078ed1493d.json
tests: remove unnecessary cd
Library/Homebrew/test/test_integration_cmds.rb
@@ -152,10 +152,8 @@ class Testball < Formula url "https://example.com/testball-0.1.tar.gz" end EOS - HOMEBREW_CACHE.cd do - assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, - cmd_output("bottle", "--no-revision", "testball")) - end + assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, + cmd_output("bottle", "--no-revision", "testball")) ensure cmd("uninstall", "--force", "testball") cmd("cleanup", "--force", "--prune=all")
false
Other
Homebrew
brew
8749ecc3839c6093f56c6b80ebf794266a611472.json
Dependency.expand: ensure pop stack During the dependencies expansion, there may be errors (e.g. FormulaUnavaiableError). As result, some deps will be left behind in the stack and interfere afterwards dependencies expansion. So let's ensure stack clean for each expansions. Fixes Homebrew/homebrew#48834.
Library/Homebrew/dependency.rb
@@ -95,8 +95,9 @@ def expand(dependent, deps = dependent.deps, &block) end end - @expand_stack.pop merge_repeats(expanded_deps) + ensure + @expand_stack.pop end def action(dependent, dep, &_block)
false
Other
Homebrew
brew
e94546121284c6178385ebb2a74a84d04632ce51.json
Tips-N'-Tricks: fix symlink for zsh completion From `Library/Contributions/brew_zsh_completion.zsh`: ````bash ```` Then it should give symlinked file name of `_brew` instead of being just `brew_zsh_completion.zsh` Closes Homebrew/homebrew#48897. Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
share/doc/homebrew/Tips-N'-Tricks.md
@@ -55,7 +55,7 @@ source $(brew --repository)/Library/Contributions/brew_bash_completion.sh Run in terminal (may require `sudo`): ```zsh -ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" /usr/local/share/zsh/site-functions +ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" /usr/local/share/zsh/site-functions/_brew ``` ## Pre-downloading a file for a formula
false
Other
Homebrew
brew
268fa841deec9d18bfa0e16b109b7cf0d08099ec.json
tests: fix simplecov handling in integration tests Closes Homebrew/homebrew#48250. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Library/Homebrew/test/test_integration_cmds.rb
@@ -30,7 +30,14 @@ def cmd_output(*args) -rconfig -rintegration_mocks ] - cmd_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] + if ENV["HOMEBREW_TESTS_COVERAGE"] + # This is needed only because we currently use a patched version of + # simplecov, and gems installed through git are not available without + # requiring bundler/setup first. See also the comment in test/Gemfile. + # Remove this line when we'll switch back to a stable simplecov release. + cmd_args << "-rbundler/setup" + cmd_args << "-rsimplecov" + end cmd_args << (HOMEBREW_LIBRARY_PATH/"../brew.rb").resolved_path.to_s cmd_args += args Bundler.with_original_env do
false
Other
Homebrew
brew
aec4e0723a909f3db42475d3c97bb5204aeaffef.json
tests: track all files
Library/Homebrew/test/.simplecov
@@ -11,6 +11,13 @@ SimpleCov.start do add_filter "Homebrew/compat/" add_filter "Homebrew/test/" add_filter "Homebrew/vendor/" + add_filter "Taps/" + + # Not using this during integration tests makes the tests 4x times faster + # without changing the coverage. + unless ENV["HOMEBREW_INTEGRATION_TEST"] + track_files "#{SimpleCov.root}/**/*.rb" + end end if ENV["HOMEBREW_INTEGRATION_TEST"]
false
Other
Homebrew
brew
abf81f98454555f7d2254b27b67abe73e833e65e.json
tests: use our patched simplecov, bump coveralls We must bump coveralls otherwise we get a conflicting dependency: we use a patched simplecov v0.11.1 but coveralls 0.8.9 needs simplecov 0.10.x.
Library/Homebrew/test/Gemfile
@@ -3,5 +3,16 @@ source "https://rubygems.org" gem "mocha", "~> 1.1" gem "minitest", "~> 5.3" gem "rake", "~> 10.3" -gem "simplecov", "~> 0.10.0", :require => false -gem "coveralls", "0.8.9", :require => false +# This is a patched version of the v0.11.2. Switch back to the stable version +# when #436 has been merged upstream. +# https://github.com/colszowka/simplecov/pull/436 +# See also https://github.com/Homebrew/homebrew/pull/48250#issuecomment-173171990 +gem "simplecov", "0.11.2", + :git => "https://github.com/Homebrew/simplecov.git", + :branch => "tracked-files-root-fix", + :require => false +gem "coveralls", "0.8.10", :require => false +# We need to pin these versions because those are the last supporting Ruby 1.8. +# Remove these lines when we've stopped supporting it. +gem "mime-types", "~> 1.16" +gem "rest-client", "1.6.9"
true
Other
Homebrew
brew
abf81f98454555f7d2254b27b67abe73e833e65e.json
tests: use our patched simplecov, bump coveralls We must bump coveralls otherwise we get a conflicting dependency: we use a patched simplecov v0.11.1 but coveralls 0.8.9 needs simplecov 0.10.x.
Library/Homebrew/test/Gemfile.lock
@@ -1,27 +1,33 @@ +GIT + remote: https://github.com/Homebrew/simplecov.git + revision: 4c7642496e902ba9028a74500971e40b3e3aaa29 + branch: tracked-files-root-fix + specs: + simplecov (0.11.2) + docile (~> 1.1.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + GEM remote: https://rubygems.org/ specs: - coveralls (0.8.9) + coveralls (0.8.10) json (~> 1.8) rest-client (>= 1.6.8, < 2) - simplecov (~> 0.10.0) + simplecov (~> 0.11.0) term-ansicolor (~> 1.3) thor (~> 0.19.1) tins (~> 1.6.0) docile (1.1.5) json (1.8.3) metaclass (0.0.4) mime-types (1.25.1) - minitest (5.8.3) + minitest (5.8.4) mocha (1.1.0) metaclass (~> 0.0.1) - rake (10.4.2) + rake (10.5.0) rest-client (1.6.9) mime-types (~> 1.16) - simplecov (0.10.0) - docile (~> 1.1.0) - json (~> 1.8) - simplecov-html (~> 0.10.0) simplecov-html (0.10.0) term-ansicolor (1.3.2) tins (~> 1.0) @@ -32,11 +38,13 @@ PLATFORMS ruby DEPENDENCIES - coveralls (= 0.8.9) + coveralls (= 0.8.10) + mime-types (~> 1.16) minitest (~> 5.3) mocha (~> 1.1) rake (~> 10.3) - simplecov (~> 0.10.0) + rest-client (= 1.6.9) + simplecov (= 0.11.2)! BUNDLED WITH 1.11.2
true
Other
Homebrew
brew
d45467172d385f56a660e999f1df97e7fb21d98b.json
tests: enforce min. 40% coverage
Library/Homebrew/test/.simplecov
@@ -3,7 +3,7 @@ SimpleCov.start do tests_path = File.dirname(__FILE__) - minimum_coverage 60 + minimum_coverage 40 coverage_dir File.expand_path("#{tests_path}/coverage") root File.expand_path("#{tests_path}/../../")
false
Other
Homebrew
brew
49990ee93fddb74cb36cec8d7b17946a853ed39c.json
ENV: use HOMEBREW_RUBY_PATH in compiler/SCM shims Use the same interpreter for the shims that is also used to run the main Homebrew process (the one invoked via `brew`). The magic basically lies in executing `ruby` with the `-x` option (supported since at least 1.8) and in the following shebang line.
Library/ENV/4.3/cc
@@ -1,6 +1,8 @@ -#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0 +#!/bin/sh +# Make sure this shim uses the same Ruby interpreter that is used by Homebrew. +exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@" +#!/usr/bin/env ruby -W0 -$:.unshift Dir["/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/{1.8,2.0.0}"].first require "pathname" require "set"
true
Other
Homebrew
brew
49990ee93fddb74cb36cec8d7b17946a853ed39c.json
ENV: use HOMEBREW_RUBY_PATH in compiler/SCM shims Use the same interpreter for the shims that is also used to run the main Homebrew process (the one invoked via `brew`). The magic basically lies in executing `ruby` with the `-x` option (supported since at least 1.8) and in the following shebang line.
Library/ENV/scm/git
@@ -1,4 +1,8 @@ -#!/usr/bin/ruby -W0 +#!/bin/sh +# Make sure this shim uses the same Ruby interpreter that is used by Homebrew. +exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@" +#!/usr/bin/env 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.
true
Other
Homebrew
brew
12a452557d7695dba69f488a95a77a2650d28251.json
make HOMEBREW_BREW_FILE a Pathname object Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_* variables are all Pathname. This commit unifies them all as Pathname, so it will not cause any confusion. Closes Homebrew/homebrew#48872. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/config.rb
@@ -26,8 +26,9 @@ def mkpath # Where brews installed via URL are cached HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula" -HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"] -unless HOMEBREW_BREW_FILE +if ENV["HOMEBREW_BREW_FILE"] + HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) +else odie "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end
true
Other
Homebrew
brew
12a452557d7695dba69f488a95a77a2650d28251.json
make HOMEBREW_BREW_FILE a Pathname object Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_* variables are all Pathname. This commit unifies them all as Pathname, so it will not cause any confusion. Closes Homebrew/homebrew#48872. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/extend/fileutils.rb
@@ -17,8 +17,8 @@ def mktemp(prefix = name) # Reference from `man 2 open` # > When a new file is created, it is given the group of the directory which # contains it. - group_id = if File.grpowned? HOMEBREW_BREW_FILE - File.stat(HOMEBREW_BREW_FILE).gid + group_id = if HOMEBREW_BREW_FILE.grpowned? + HOMEBREW_BREW_FILE.stat.gid else Process.gid end
true
Other
Homebrew
brew
12a452557d7695dba69f488a95a77a2650d28251.json
make HOMEBREW_BREW_FILE a Pathname object Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_* variables are all Pathname. This commit unifies them all as Pathname, so it will not cause any confusion. Closes Homebrew/homebrew#48872. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/formula.rb
@@ -871,7 +871,7 @@ def skip_clean?(path) # @private def link_overwrite?(path) # Don't overwrite files not created by Homebrew. - return false unless path.stat.uid == File.stat(HOMEBREW_BREW_FILE).uid + return false unless path.stat.uid == HOMEBREW_BREW_FILE.stat.uid # Don't overwrite files belong to other keg except when that # keg's formula is deleted. begin
true
Other
Homebrew
brew
12a452557d7695dba69f488a95a77a2650d28251.json
make HOMEBREW_BREW_FILE a Pathname object Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_* variables are all Pathname. This commit unifies them all as Pathname, so it will not cause any confusion. Closes Homebrew/homebrew#48872. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/Homebrew/test/lib/config.rb
@@ -1,7 +1,7 @@ require "tmpdir" require "pathname" -HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"] +HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) HOMEBREW_TEMP = Pathname.new(ENV["HOMEBREW_TEMP"] || Dir.tmpdir) TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") { |k|
true
Other
Homebrew
brew
12a452557d7695dba69f488a95a77a2650d28251.json
make HOMEBREW_BREW_FILE a Pathname object Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_* variables are all Pathname. This commit unifies them all as Pathname, so it will not cause any confusion. Closes Homebrew/homebrew#48872. Signed-off-by: Xu Cheng <xucheng@me.com>
Library/brew.rb
@@ -104,7 +104,7 @@ def require?(path) end if possible_tap && !possible_tap.installed? - brew_uid = File.stat(HOMEBREW_BREW_FILE).uid + brew_uid = HOMEBREW_BREW_FILE.stat.uid tap_commands = [] if Process.uid.zero? && !brew_uid.zero? tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}]
true
Other
Homebrew
brew
58cf0ec2b908d4bcd12d77036ef8eac60ee95697.json
audit: add check for insecure hackage urls
Library/Homebrew/cmd/audit.rb
@@ -1126,6 +1126,7 @@ def audit_urls %r{^http://www\.mirrorservice\.org/}, %r{^http://launchpad\.net/}, %r{^http://bitbucket\.org/}, + %r{^http://hackage\.haskell\.org/}, %r{^http://(?:[^/]*\.)?archive\.org} problem "Please use https:// for #{p}" when %r{^http://search\.mcpan\.org/CPAN/(.*)}i
false
Other
Homebrew
brew
984a70e6e22241d0a9be21d333dca1757b2a3bfa.json
use BSD stat Closes Homebrew/homebrew#48803.
bin/brew
@@ -141,7 +141,7 @@ elif [[ -n "$HOMEBREW_DEVELOPER" && -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOME HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" fi -if [[ "$(id -u)" = "0" && "$(stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] +if [[ "$(id -u)" = "0" && "$(/usr/bin/stat -f%u "$HOMEBREW_BREW_FILE")" != "0" ]] then case "$HOMEBREW_COMMAND" in instal|install|reinstall|postinstall|ln|link|pin|update|update-bash|upgrade|create|migrate|tap|switch)
false
Other
Homebrew
brew
35e2209c10ffcf6a666ac4a8051a1f20801895ea.json
architecture_list: add new module. remove old mach.rb, replace with cctools_mach.rb and prune ELF case move ArchitectureListExtension to separate file ELF support is maintained in Linuxbrew
Library/Homebrew/os/mac/architecture_list.rb
@@ -0,0 +1,52 @@ +module ArchitectureListExtension + # @private + def fat? + length > 1 + end + + # @private + def intel_universal? + intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS) + end + + # @private + def ppc_universal? + intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::PPC_64BIT_ARCHS) + end + + # Old-style 32-bit PPC/Intel universal, e.g. ppc7400 and i386 + # @private + def cross_universal? + intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::INTEL_32BIT_ARCHS) + end + + # @private + def universal? + intel_universal? || ppc_universal? || cross_universal? + end + + def ppc? + (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a } + end + + # @private + def remove_ppc! + (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a } + end + + def as_arch_flags + collect { |a| "-arch #{a}" }.join(" ") + end + + def as_cmake_arch_flags + join(";") + end + + protected + + def intersects_all?(*set) + set.all? do |archset| + archset.any? { |a| self.include? a } + end + end +end
true
Other
Homebrew
brew
35e2209c10ffcf6a666ac4a8051a1f20801895ea.json
architecture_list: add new module. remove old mach.rb, replace with cctools_mach.rb and prune ELF case move ArchitectureListExtension to separate file ELF support is maintained in Linuxbrew
Library/Homebrew/os/mac/cctools_mach.rb
@@ -1,57 +1,6 @@ -module ArchitectureListExtension - # @private - def fat? - length > 1 - end - - # @private - def intel_universal? - intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS) - end - - # @private - def ppc_universal? - intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::PPC_64BIT_ARCHS) - end - - # Old-style 32-bit PPC/Intel universal, e.g. ppc7400 and i386 - # @private - def cross_universal? - intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::INTEL_32BIT_ARCHS) - end - - # @private - def universal? - intel_universal? || ppc_universal? || cross_universal? - end - - def ppc? - (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a } - end - - # @private - def remove_ppc! - (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a } - end - - def as_arch_flags - collect { |a| "-arch #{a}" }.join(" ") - end - - def as_cmake_arch_flags - join(";") - end - - protected - - def intersects_all?(*set) - set.all? do |archset| - archset.any? { |a| self.include? a } - end - end -end +require "os/mac/architecture_list" -module MachO +module CctoolsMachO # @private OTOOL_RX = /\t(.*) \(compatibility version (?:\d+\.)*\d+, current version (?:\d+\.)*\d+\)/ @@ -77,8 +26,6 @@ def mach_data end when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch offsets << 0 - when 0x7f454c46 # ELF - mach_data << { :arch => :x86_64, :type => :executable } else raise "Not a Mach-O binary." end
true
Other
Homebrew
brew
37e423ebb2885f9f5799b9914357124b98e79643.json
os/mac/hardware: add Skylake CPU. Closes Homebrew/homebrew#48781. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/os/mac/hardware.rb
@@ -48,6 +48,8 @@ def family :haswell when 0x582ed09c # Broadwell :broadwell + when 0x37fc219f # Skylake + :skylake else :dunno end
true
Other
Homebrew
brew
37e423ebb2885f9f5799b9914357124b98e79643.json
os/mac/hardware: add Skylake CPU. Closes Homebrew/homebrew#48781. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/Homebrew/test/test_hardware.rb
@@ -7,7 +7,7 @@ def test_hardware_cpu_type end def test_hardware_intel_family - families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell] + families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake] assert_includes families, Hardware::CPU.family end if Hardware::CPU.intel? end
true
Other
Homebrew
brew
87ee0ab3afb407e74162f8b300df5ef14b664916.json
doc: fix typos in Formula Cookbook `preprended` > `prepended` Replace `a` with `an` `throughly` > `thoroughly` Remove extra `consider` Closes Homebrew/homebrew#48697. Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
share/doc/homebrew/Formula-Cookbook.md
@@ -74,7 +74,7 @@ so you can override this with `brew create <url> --set-name <name>`. A SSL/TLS (https) [`homepage`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#homepage%3D-class_method) is preferred, if one is available. -Try to summarize from the [`homepage`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#homepage%3D-class_method) what the formula does in the [`desc`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#desc%3D-class_method)ription. Note that the [`desc`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#desc%3D-class_method)ription is automatically preprended with the formula name. +Try to summarize from the [`homepage`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#homepage%3D-class_method) what the formula does in the [`desc`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#desc%3D-class_method)ription. Note that the [`desc`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#desc%3D-class_method)ription is automatically prepended with the formula name. ## Check the build system @@ -165,7 +165,7 @@ Sometimes there’s hard conflict between formulae, and it can’t be avoided or `mbedtls` ships and compiles a "Hello World" executable. This is obviously non-essential to `mbedtls`’s functionality, and conflict with the popular GNU `hello` formula would be overkill, so we just remove it. [pdftohtml](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/pdftohtml.rb) provides an example of a serious -conflict, where both formula ship a identically-named binary that is essential to functionality, so a [`conflicts_with`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#conflicts_with-class_method) is preferable. +conflict, where both formula ship an identically-named binary that is essential to functionality, so a [`conflicts_with`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#conflicts_with-class_method) is preferable. As a general rule, [`conflicts_with`](http://www.rubydoc.info/github/Homebrew/homebrew/master/Formula#conflicts_with-class_method) should be a last-resort option. It’s a fairly blunt instrument. @@ -303,7 +303,7 @@ The established standard for Git commit messages is: * the first line is a commit summary of *50 characters or less* * two (2) newlines, then -* explain the commit throughly +* explain the commit thoroughly At Homebrew, we like to put the name of the formula up front like so: `foobar 7.3 (new formula)`. This may seem crazy short, but you’ll find that forcing yourself to summarise the commit encourages you to be atomic and concise. If you can’t summarise it in 50-80 characters, you’re probably trying to commit two commits as one. For a more thorough explanation, please read Tim Pope’s excellent blog post, [A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). @@ -815,7 +815,7 @@ When using Homebrew's `gfortran` compiler, the standard `CFLAGS` are used and us # How to start over (reset to upstream `master`) -Have you created a real mess in git which stops you from creating a commit you want to submit to us? You might want to consider consider starting again from scratch. Your changes can be reset to the Homebrew's `master` branch by running: +Have you created a real mess in git which stops you from creating a commit you want to submit to us? You might want to consider starting again from scratch. Your changes can be reset to the Homebrew's `master` branch by running: ```shell git checkout -f master
false
Other
Homebrew
brew
6cccc2d0fefe2474fb34e44c849ce0c0375c3a88.json
tests: remove unnecessary code
Library/Homebrew/test/test_integration_cmds.rb
@@ -267,13 +267,12 @@ class Testball < Formula def test_desc formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula desc "Some test" url "https://example.com/testball-0.1.tar.gz" end EOS - formula_file.write content assert_equal "testball: Some test", cmd("desc", "testball") ensure @@ -283,13 +282,12 @@ class Testball < Formula def test_edit (HOMEBREW_REPOSITORY/".git").mkpath formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "https://example.com/testball-0.1.tar.gz" # something here end EOS - formula_file.write content assert_match "# something here", cmd("edit", "testball", {"HOMEBREW_EDITOR" => "/bin/cat"}) @@ -305,12 +303,11 @@ def test_sh def test_info formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "https://example.com/testball-0.1.tar.gz" end EOS - formula_file.write content assert_match "testball: stable 0.1", cmd("info", "testball") @@ -330,12 +327,11 @@ def test_tap_readme def test_unpack formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" end EOS - formula_file.write content mktmpdir do |path| cmd "unpack", "testball", "--destdir=#{path}" @@ -349,14 +345,13 @@ class Testball < Formula def test_options formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" option "with-foo", "foobar" depends_on "bar" => :recommended end EOS - formula_file.write content assert_equal "--with-foo\n\tfoobar\n--without-bar\n\tBuild without bar support", cmd_output("options", "testball").chomp @@ -366,13 +361,11 @@ class Testball < Formula def test_outdated formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" end EOS - formula_file.write content - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath assert_equal "testball", cmd("outdated") @@ -383,7 +376,7 @@ class Testball < Formula def test_upgrade formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" sha256 "#{TESTBALL_SHA256}" @@ -393,7 +386,6 @@ def install end end EOS - formula_file.write content (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath @@ -412,12 +404,11 @@ def test_linkapps apps_dir.mkpath formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "https://example.com/testball-0.1.tar.gz" end EOS - formula_file.write content source_dir = HOMEBREW_CELLAR/"testball/0.1/TestBall.app" source_dir.mkpath @@ -435,12 +426,11 @@ def test_unlinkapps apps_dir.mkpath formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "https://example.com/testball-0.1.tar.gz" end EOS - formula_file.write content source_app = (HOMEBREW_CELLAR/"testball/0.1/TestBall.app") source_app.mkpath @@ -457,7 +447,7 @@ class Testball < Formula def test_pin_unpin formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" sha256 "#{TESTBALL_SHA256}" @@ -467,8 +457,6 @@ def install end end EOS - formula_file.write content - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath cmd("pin", "testball") @@ -488,7 +476,7 @@ def install def test_reinstall formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" sha256 "#{TESTBALL_SHA256}" @@ -501,7 +489,6 @@ def install end end EOS - formula_file.write content cmd("install", "testball", "--with-foo") foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo" @@ -549,13 +536,12 @@ def test_create def test_fetch formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb" - content = <<-EOS.undent + formula_file.write <<-EOS.undent class Testball < Formula url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" sha256 "#{TESTBALL_SHA256}" end EOS - formula_file.write content cmd("fetch", "testball") assert (HOMEBREW_CACHE/"testball-0.1.tbz").exist?,
false
Other
Homebrew
brew
cdd990f9d70b83956d931b4f48d6f9c3ba53023a.json
audit: use start_with? to check the name in the desc
Library/Homebrew/cmd/audit.rb
@@ -411,7 +411,7 @@ def audit_desc problem "Description shouldn't start with an indefinite article (#{$1})" end - if desc =~ /^#{formula.name}\s/i + if desc.downcase.start_with? "#{formula.name} " problem "Description shouldn't include the formula name" end end
false
Other
Homebrew
brew
5b89c33cac47cb01f63c0a3593ea48d22087802f.json
pull: fix ambiguity issues for tap migrations `Formula[name]` gets called with an unqualified name and thus will throw `TapFormulaAmbiguityError` exceptions (silently ignored) if both the old and the new tap are present and changes for the new tap are pulled before the migrated formulae are removed from the old tap. The result is an empty or incomplete `changed_formulae`, causing issues with pulling the corresponding bottles and possibly other problems, too.
Library/Homebrew/cmd/pull.rb
@@ -100,7 +100,7 @@ def pull "git", "diff-tree", "-r", "--name-only", "--diff-filter=AM", revision, "HEAD", "--", tap.formula_dir.to_s ).each_line do |line| - name = File.basename(line.chomp, ".rb") + name = "#{tap.name}/#{File.basename(line.chomp, ".rb")}" begin changed_formulae << Formula[name]
false
Other
Homebrew
brew
604323e641ccd0b125716f4a337b1f9384236716.json
brew.rb: use $stderr for debug and errors. Closes Homebrew/homebrew#48634. Closes Homebrew/homebrew#48681. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Library/brew.rb
@@ -75,7 +75,11 @@ def require?(path) if empty_argv || (help_flag && (cmd.nil? || internal_cmd)) # TODO: - `brew help cmd` should display subcommand help require "cmd/help" - puts ARGV.usage + if empty_argv + $stderr.puts ARGV.usage + else + puts ARGV.usage + end exit ARGV.any? ? 0 : 1 end @@ -123,26 +127,26 @@ def require?(path) abort ARGV.usage rescue SystemExit => e onoe "Kernel.exit" if ARGV.verbose? && !e.success? - puts e.backtrace if ARGV.debug? + $stderr.puts e.backtrace if ARGV.debug? raise rescue Interrupt => e - puts # seemingly a newline is typical + $stderr.puts # seemingly a newline is typical exit 130 rescue BuildError => e e.dump exit 1 rescue RuntimeError, SystemCallError => e raise if e.message.empty? onoe e - puts e.backtrace if ARGV.debug? + $stderr.puts e.backtrace if ARGV.debug? exit 1 rescue Exception => e onoe e if internal_cmd - puts "#{Tty.white}Please report this bug:" - puts " #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}" + $stderr.puts "#{Tty.white}Please report this bug:" + $stderr.puts " #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}" end - puts e.backtrace + $stderr.puts e.backtrace exit 1 else exit 1 if Homebrew.failed?
false
Other
Homebrew
brew
40a287f3c3d09a12b92b5594e09331b9998c5075.json
config.rb: add comment explaining HOMEBREW_TEMP logic
Library/Homebrew/config.rb
@@ -45,6 +45,7 @@ def mkpath HOMEBREW_LOGS = Pathname.new(ENV["HOMEBREW_LOGS"] || "~/Library/Logs/Homebrew/").expand_path +# Must use /tmp instead of $TMPDIR because long paths break Unix domain sockets HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/tmp")) unless defined? HOMEBREW_LIBRARY_PATH
false
Other
Homebrew
brew
c6e0c9538fdb2a5463bcb28eaa5586cebcb9000b.json
test_cmd_audit: add resource placement test
Library/Homebrew/test/test_cmd_audit.rb
@@ -156,6 +156,23 @@ class Foo < Formula fa.problems end + def test_audit_file_strict_resource_placement + fa = formula_auditor "foo", <<-EOS.undent, :strict => true + class Foo < Formula + url "https://example.com/foo-1.0.tgz" + + resource "foo2" do + url "https://example.com/foo-2.0.tgz" + end + + depends_on "openssl" + end + EOS + fa.audit_file + assert_equal ["`depends_on` (line 8) should be put before `resource` (line 4)"], + fa.problems + end + def test_audit_file_strict_url_outside_of_stable_block fa = formula_auditor "foo", <<-EOS.undent, :strict => true class Foo < Formula
false