* Move GitHub API module to utils/github.rb.
* Move curl method to utils/curl.rb.
* global: use long curl arguments and an array.
This makes the code more self-documenting.
* utils/curl: support reading curl's output.
* utils/github: use curl instead of open-uri.
It has far better proxy support.
* pull: set Homebrew user agent.
* gist-logs: remove trailing whitespace.
* gist-logs: use first instead of [0].
Easier to read.
* gist-logs: use curl-based GitHub.open method.
Avoid breaking code highlighting of some editors (e.g. Sublime Text)
when `gem` is used as an identifier. This messes up the highlighting
below the first use and makes working with the file rather annoying.
If the environment variable HOMEBREW_TEST_GENERIC_OS is set ensure that
neither Mac nor Linux-specific code is loaded. This allows easier
testing of cross-platform code on OS X and will make it easier to port
Homebrew to platforms other than OS X and Linux.
This collects all violations for each formula in a single place, instead
of doing `brew style` outputs for all formulae first, and then the other
audit checks.
Closes#112.
Signed-off-by: Andrew Janke <andrew@apjanke.net>
Also enables sandbox for --interactive and --debug use of install
and test, using automatic retention.
Closes#66.
Signed-off-by: Andrew Janke <andrew@apjanke.net>
This can happen when `HOMEBREW_CURL` is set to brewed curl, but during
`brew resinstall curl`, brewed curl's symlink is temporary
unlinked.
So let's fallback to /usr/bin/curl in this case.
Generally it seems user agents are all `software/version` but ours is
not. Also, set the user agent in a way that it's shared between Bash
and Ruby code.
Closes https://github.com/Homebrew/legacy-homebrew/pull/50480.
The API used (`Net::HTTP::Post`) does not handle basic authentication
credentials in the same way as `open` so fix both cases so they work.
Also, do some general usability tweaks to point out to people what could
be wrong with their tokens or credentials to help them debug.
ClosesHomebrew/homebrew#50410.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
- Use empty array when `git credential-osxkeychain` lookup fails to
cache and avoid rerunning it when there's no valid results.
- Redirect `stderr` to avoid printing errors when there's a failure
or no `git credential-osxkeychain` installed.
ClosesHomebrew/homebrew#49954.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This avoids crashing with an unknown key error, if the GitHub api
response does not contain the ratelimit headers, e.g. when GitHub is
down. It also tries to display the JSON error message in addition to
the HTTP status.
ClosesHomebrew/homebrew#48538.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Particularly the `bundler` Gem requires the right Ruby binary to be in
the PATH to work correctly if the Ruby binary used to run Homebrew is
overridden via `HOMEBREW_RUBY_PATH` and thus intentionally not prefixed
to the PATH (as that would affect formulae with a Ruby dependency).
The workaround here is to prefix this path only when a Gem is activated
via `Homebrew.install_gem_setup_path!` (currently used in `brew man`,
`brew style`, and `brew tests`).
Also reuse this improved implementation in the GitHub rate limit errors.
ClosesHomebrew/homebrew#44721.
Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Without this the returned string is not as accurate if the method is
called with an int larger than 120.
ClosesHomebrew/homebrew#47002.
Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Setting the environment variable `HOMEBREW_RUBY_PATH` allows one to run
Homebrew with a non-standard Ruby, even one that is not in `PATH`. This
creates the problem that the `gem` in `PATH` might not be the right one
to call, possibly leading to confusing results as the wrong RubyGems
installation is queried/manipulated.
ClosesHomebrew/homebrew#46185.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
The yellow background made the text unreadable for light-on-dark color
schemes. Fix by making the highlighted text just bold.
FixesHomebrew/homebrew#45028.
ClosesHomebrew/homebrew#45030.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Two methods:
* `Utils.git_available?` checks whether git is installed.
* `Utils.ensure_git_installed!` installs git for users who don't install
Xcode or CLT.