diff options
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/cleanup.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/diy.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/info.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/install.rb | 23 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/postinstall.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/reinstall.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/search.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/style.rb | 32 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/uninstall.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update-report.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update.sh | 44 |
11 files changed, 85 insertions, 74 deletions
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index a9d3fbcde..6e0915c9a 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -22,13 +22,13 @@ module Homebrew ARGV.resolved_formulae.each { |f| Cleanup.cleanup_formula f } end - if Cleanup.disk_cleanup_size > 0 - disk_space = disk_usage_readable(Cleanup.disk_cleanup_size) - if ARGV.dry_run? - ohai "This operation would free approximately #{disk_space} of disk space." - else - ohai "This operation has freed approximately #{disk_space} of disk space." - end + return if Cleanup.disk_cleanup_size.zero? + + disk_space = disk_usage_readable(Cleanup.disk_cleanup_size) + if ARGV.dry_run? + ohai "This operation would free approximately #{disk_space} of disk space." + else + ohai "This operation has freed approximately #{disk_space} of disk space." end end end diff --git a/Library/Homebrew/cmd/diy.rb b/Library/Homebrew/cmd/diy.rb index 8262352f8..95ec7fe35 100644 --- a/Library/Homebrew/cmd/diy.rb +++ b/Library/Homebrew/cmd/diy.rb @@ -31,11 +31,9 @@ module Homebrew def detect_version(path) version = path.version.to_s - if version.empty? - raise "Couldn't determine version, set it with --version=<version>" - else - version - end + raise "Couldn't determine version, set it with --version=<version>" if version.empty? + + version end def detect_name(path, version) diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 2474aad57..09c832203 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -54,11 +54,8 @@ module Homebrew end rescue FormulaUnavailableError # No formula with this name, try a blacklist lookup - if (blacklist = blacklisted?(f)) - puts blacklist - else - raise - end + raise unless (blacklist = blacklisted?(f)) + puts blacklist end end end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 50439ccf9..8a8323252 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -203,13 +203,12 @@ module Homebrew # If they haven't updated in 48 hours (172800 seconds), that # might explain the error master = HOMEBREW_REPOSITORY/".git/refs/heads/master" - if master.exist? && (Time.now.to_i - File.mtime(master).to_i) > 172800 - ohai "You haven't updated Homebrew in a while." - puts <<-EOS.undent - A formula for #{e.name} might have been added recently. - Run `brew update` to get the latest Homebrew updates! - EOS - end + return unless master.exist? && (Time.now.to_i - File.mtime(master).to_i) > 172800 + ohai "You haven't updated Homebrew in a while." + puts <<-EOS.undent + A formula for #{e.name} might have been added recently. + Run `brew update` to get the latest Homebrew updates! + EOS end end end @@ -245,11 +244,11 @@ module Homebrew end def check_macports - unless MacOS.macports_or_fink.empty? - opoo "It appears you have MacPorts or Fink installed." - puts "Software installed with other package managers causes known problems for" - puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again." - end + return if MacOS.macports_or_fink.empty? + + opoo "It appears you have MacPorts or Fink installed." + puts "Software installed with other package managers causes known problems for" + puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again." end def check_cellar diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb index 71b71b3f5..e0bd8e31b 100644 --- a/Library/Homebrew/cmd/postinstall.rb +++ b/Library/Homebrew/cmd/postinstall.rb @@ -36,7 +36,7 @@ module Homebrew sandbox.allow_write_cellar(formula) sandbox.allow_write_xcode sandbox.allow_write_path HOMEBREW_PREFIX - sandbox.deny_write_homebrew_library + sandbox.deny_write_homebrew_repository sandbox.exec(*args) else exec(*args) diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index e51aace2a..bda6022bf 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -58,10 +58,11 @@ module Homebrew def restore_backup(keg, formula) path = backup_path(keg) - if path.directory? - path.rename keg - keg.link unless formula.keg_only? - end + + return unless path.directory? + + path.rename keg + keg.link unless formula.keg_only? end def backup_path(path) diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 50d9f5f74..aa80ec589 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -150,7 +150,7 @@ module Homebrew names = remote_tap_formulae["#{user}/#{repo}"] user = user.downcase if user == "Homebrew" # special handling for the Homebrew organization - names.select { |name| rx === name }.map { |name| "#{user}/#{repo}/#{name}" } + names.select { |name| name =~ rx }.map { |name| "#{user}/#{repo}/#{name}" } rescue GitHub::HTTPNotFoundError opoo "Failed to search tap: #{user}/#{repo}. Please run `brew update`" [] @@ -171,10 +171,11 @@ module Homebrew rescue canonical_name = canonical_full_name = name end + # Ignore aliases from results when the full name was also found - if aliases.include?(name) && results.include?(canonical_full_name) - next - elsif (HOMEBREW_CELLAR/canonical_name).directory? + next if aliases.include?(name) && results.include?(canonical_full_name) + + if (HOMEBREW_CELLAR/canonical_name).directory? pretty_installed(name) else name diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index f28d50cc1..db61116be 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -45,7 +45,7 @@ module Homebrew def check_style_impl(files, output_type, options = {}) fix = options[:fix] - Homebrew.install_gem_setup_path! "rubocop", "0.41.2" + Homebrew.install_gem_setup_path! "rubocop", "0.43.0" args = %W[ --force-exclusion @@ -54,20 +54,22 @@ module Homebrew args << "--auto-correct" if fix args += files - case output_type - when :print - args << "--display-cop-names" if ARGV.include? "--display-cop-names" - system "rubocop", "--format", "simple", *args - !$?.success? - when :json - json = Utils.popen_read_text("rubocop", "--format", "json", *args) - # exit status of 1 just means violations were found; other numbers mean execution errors - # exitstatus can also be nil if RuboCop process crashes, e.g. due to - # native extension problems - raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1 - RubocopResults.new(Utils::JSON.load(json)) - else - raise "Invalid output_type for check_style_impl: #{output_type}" + HOMEBREW_LIBRARY.cd do + case output_type + when :print + args << "--display-cop-names" if ARGV.include? "--display-cop-names" + system "rubocop", "--format", "simple", *args + !$?.success? + when :json + json = Utils.popen_read_text("rubocop", "--format", "json", *args) + # exit status of 1 just means violations were found; other numbers mean execution errors + # exitstatus can also be nil if RuboCop process crashes, e.g. due to + # native extension problems + raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1 + RubocopResults.new(Utils::JSON.load(json)) + else + raise "Invalid output_type for check_style_impl: #{output_type}" + end end end diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index 6ea45a770..f4ca8ff87 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -25,7 +25,7 @@ module Homebrew versions = rack.subdirs.map(&:basename) verb = versions.length == 1 ? "is" : "are" puts "#{keg.name} #{versions.join(", ")} #{verb} still installed." - puts "Remove them all with `brew uninstall --force #{keg.name}`." + puts "Remove all versions with `brew uninstall --force #{keg.name}`." end end end diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 1e9c8ccd3..18f2f370c 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -549,11 +549,10 @@ class ReporterHub end end - unless formulae.empty? - # Dump formula list. - ohai title - puts_columns(formulae) - end + return if formulae.empty? + # Dump formula list. + ohai title + puts_columns(formulae) end def installed?(formula) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index b57691893..579890820 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -215,7 +215,20 @@ merge_or_rebase() { trap reset_on_interrupt SIGINT - REMOTE_REF="origin/$UPSTREAM_BRANCH" + if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -z "$HOMEBREW_NO_UPDATE_CLEANUP" ]] + then + UPSTREAM_TAG="$(git tag --list --sort=-version:refname | grep '^[0-9]*\.[0-9]*\.[0-9]*$' | head -n1)" + else + UPSTREAM_TAG="" + fi + + if [ -n "$UPSTREAM_TAG" ] + then + REMOTE_REF="refs/tags/$UPSTREAM_TAG" + UPSTREAM_BRANCH="stable" + else + REMOTE_REF="origin/$UPSTREAM_BRANCH" + fi if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]] then @@ -242,19 +255,13 @@ EOS fi INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)" - if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]] + if [[ -n "$UPSTREAM_TAG" ]] || + [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]] then - - if [[ -z "$HOMEBREW_NO_UPDATE_CLEANUP" ]] - then - echo "Checking out $UPSTREAM_BRANCH in $DIR..." - echo "To checkout $INITIAL_BRANCH in $DIR run:" - echo " 'cd $DIR && git checkout $INITIAL_BRANCH" - fi - # Recreate and check out `#{upstream_branch}` if unable to fast-forward # it to `origin/#{@upstream_branch}`. Otherwise, just check it out. - if git merge-base --is-ancestor "$UPSTREAM_BRANCH" "$REMOTE_REF" &>/dev/null + if [[ -z "$UPSTREAM_TAG" ]] && + git merge-base --is-ancestor "$UPSTREAM_BRANCH" "$REMOTE_REF" &>/dev/null then git checkout --force "$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}" else @@ -290,7 +297,8 @@ EOS if [[ -n "$HOMEBREW_NO_UPDATE_CLEANUP" ]] then - if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]] + if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" && + ! "$INITIAL_BRANCH" =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]] then git checkout "$INITIAL_BRANCH" "${QUIET_ARGS[@]}" fi @@ -337,7 +345,7 @@ EOS set -x fi - if [[ -z "$HOMEBREW_UPDATE_CLEANUP" ]] + if [[ -z "$HOMEBREW_UPDATE_CLEANUP" && -z "$HOMEBREW_UPDATE_TO_TAG" ]] then if [[ -n "$HOMEBREW_DEVELOPER" || -n "$HOMEBREW_DEV_CMD_RUN" ]] then @@ -425,6 +433,12 @@ EOS declare UPSTREAM_BRANCH"$TAP_VAR"="$UPSTREAM_BRANCH_DIR" declare PREFETCH_REVISION"$TAP_VAR"="$(git rev-parse -q --verify refs/remotes/origin/"$UPSTREAM_BRANCH_DIR")" + # Force a full update if we don't have any tags. + if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -z "$(git tag --list)" ]] + then + HOMEBREW_UPDATE_FORCE=1 + fi + if [[ -z "$HOMEBREW_UPDATE_FORCE" ]] then [[ -n "$SKIP_FETCH_BREW_REPOSITORY" && "$DIR" = "$HOMEBREW_REPOSITORY" ]] && continue @@ -480,10 +494,10 @@ EOS if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] then - git fetch --force "${QUIET_ARGS[@]}" origin \ + git fetch --tags --force "${QUIET_ARGS[@]}" origin \ "refs/heads/$UPSTREAM_BRANCH_DIR:refs/remotes/origin/$UPSTREAM_BRANCH_DIR" 2>/dev/null else - if ! git fetch --force "${QUIET_ARGS[@]}" origin \ + if ! git fetch --tags --force "${QUIET_ARGS[@]}" origin \ "refs/heads/$UPSTREAM_BRANCH_DIR:refs/remotes/origin/$UPSTREAM_BRANCH_DIR" then echo "Fetching $DIR failed!" >>"$update_failed_file" |
