diff --git a/Library/Homebrew/resource_auditor.rb b/Library/Homebrew/resource_auditor.rb index a8b54ee80c..f40af7ce9b 100644 --- a/Library/Homebrew/resource_auditor.rb +++ b/Library/Homebrew/resource_auditor.rb @@ -124,6 +124,21 @@ module Homebrew end end + def audit_head_branch + return if !@online || !@strict || spec_name != :head || !Utils::Git.remote_exists?(url) + + branch = Utils.popen_read("git", "ls-remote", "--symref", url, "HEAD") + .match(%r{ref: refs/heads/(.*?)\s+HEAD})[1] + + return if branch == "master" && specs[:branch].blank? || branch == specs[:branch] + + if branch == "master" + problem "Remove `branch: \"#{specs[:branch]}\"`" + else + problem "Use `branch: \"#{branch}\"` to specify the correct default branch" + end + end + def problem(text) @problems << text end