From c0331c914288d842a8cd380d96814aa5a0aac847 Mon Sep 17 00:00:00 2001 From: Adrian Ho Date: Thu, 12 Jan 2023 18:20:47 +0800 Subject: [PATCH] show/check Homebrew branch Because anyone can forget they're on a different branch, and wonder why `brew update` isn't pulling in the latest changes (https://github.com/orgs/Homebrew/discussions/4105#discussioncomment-4658869). --- Library/Homebrew/diagnostic.rb | 11 +++++++++++ Library/Homebrew/system_config.rb | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index af4a62a787..0d78061296 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -519,6 +519,17 @@ module Homebrew examine_git_origin(repo, Homebrew::EnvConfig.brew_git_remote) end + def check_brew_git_branch + repo = HOMEBREW_REPOSITORY.dup.extend(GitRepositoryExtension) + return if repo.git_default_origin_branch? + + <<~EOS + Homebrew is not on the default git origin branch and may not receive + updates. If this is a surprise to you, check out the default branch with: + git -C $(brew --repo) checkout #{repo.git_origin_branch}" + EOS + end + def check_coretap_integrity coretap = CoreTap.instance unless coretap.installed? diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index a019aa4de0..cb78c84021 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -52,6 +52,11 @@ module SystemConfig homebrew_repo.git_origin || "(none)" end + sig { returns(String) } + def branch + homebrew_repo.git_branch || "(none)" + end + sig { returns(String) } def core_tap_head CoreTap.instance.git_head || "(none)" @@ -155,6 +160,7 @@ module SystemConfig f.puts "ORIGIN: #{origin}" f.puts "HEAD: #{head}" f.puts "Last commit: #{last_commit}" + f.puts "Branch: #{branch}" end def homebrew_env_config(f = $stdout)