From 6fab5b0976addc7e8e772d86070358a55a38d281 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sat, 26 Aug 2017 10:13:43 -0700 Subject: [PATCH 1/6] Revert "diagnostic: also don't check Jenkins core branch." This reverts commit db41f9d1182ff8c4c3b42b458e38d5c58b496ffb. --- Library/Homebrew/diagnostic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index ef9f065690..3d3c5e5dc1 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -786,7 +786,7 @@ module Homebrew EOS end - return if ENV["CI"] || ENV["JENKINS_HOME"] + return if ENV["CI"] head = coretap_path.git_head return if head.nil? || head =~ %r{refs/heads/master} From 8b91018c70cb949fdc90f3316eca0d386f7f09c1 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sat, 26 Aug 2017 10:14:23 -0700 Subject: [PATCH 2/6] Revert "diagnostic: don't check CI core branch." This reverts commit cb5b14307ca4640e1ba68cfd28e7fef34a3b771b. --- Library/Homebrew/diagnostic.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 3d3c5e5dc1..8108c5da0b 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -786,7 +786,6 @@ module Homebrew EOS end - return if ENV["CI"] head = coretap_path.git_head return if head.nil? || head =~ %r{refs/heads/master} From 204f37049122c1ab371a71ae12e8d16aa8ffb23f Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sat, 26 Aug 2017 10:15:35 -0700 Subject: [PATCH 3/6] Revert "Add check for HEAD ref in diagnostics" --- Library/Homebrew/diagnostic.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 8108c5da0b..ceb6ad4d1d 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -756,7 +756,7 @@ module Homebrew end end - def check_coretap_git_config + def check_coretap_git_origin coretap_path = CoreTap.instance.path return if !Utils.git_available? || !(coretap_path/".git").exist? @@ -785,16 +785,6 @@ module Homebrew git -C "#{coretap_path}" remote set-url origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")} EOS end - - head = coretap_path.git_head - return if head.nil? || head =~ %r{refs/heads/master} - - <<-EOS.undent - Homebrew/homebrew-core is not on the master branch - - Check out the master branch by running: - git -C "$(brew --repo homebrew/core)" checkout master - EOS end def __check_linked_brew(f) From fe5c885da0b8b69a5de74647e4181b137acb835f Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Wed, 27 Sep 2017 16:32:13 -0400 Subject: [PATCH 4/6] Implement changes --- Library/Homebrew/diagnostic.rb | 13 +++++++++++++ Library/Homebrew/extend/git_repository.rb | 9 +++++++++ Library/Homebrew/tap.rb | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index ceb6ad4d1d..f42fb95e23 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -785,6 +785,19 @@ module Homebrew git -C "#{coretap_path}" remote set-url origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")} EOS end + + return if ENV["CI"] || ENV["JENKINS_HOME"] + + branch = coretap_path.git_branch + return if branch.nil? || branch =~ %r{master} + + + <<-EOS.undent + Homebrew/homebrew-core is not on the master branch + + Check out the master branch by running: + git -C "$(brew --repo homebrew/core)" checkout master + EOS end def __check_linked_brew(f) diff --git a/Library/Homebrew/extend/git_repository.rb b/Library/Homebrew/extend/git_repository.rb index c15988550f..6b89d175ca 100644 --- a/Library/Homebrew/extend/git_repository.rb +++ b/Library/Homebrew/extend/git_repository.rb @@ -36,6 +36,15 @@ module GitRepositoryExtension end end + def git_branch + return unless git? && Utils.git_available? + cd do + Utils.popen_read( + "git", "rev-parse", "--abbrev-ref", "HEAD" + ).chuzzle + end + end + def git_last_commit_date return unless git? && Utils.git_available? cd do diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index f232be4281..acf2d196b4 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -118,6 +118,12 @@ class Tap path.git? end + # git branch for this {Tap}. + def git_branch + raise TapUnavailableError, name unless installed? + path.git_branch + end + # git HEAD for this {Tap}. def git_head raise TapUnavailableError, name unless installed? From 7974ce24b619f921071dc607f0ea1a50e5379b9f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 28 Sep 2017 20:10:06 +0100 Subject: [PATCH 5/6] Fix regex style --- Library/Homebrew/diagnostic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 020594f0c5..29d2e342f7 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -789,7 +789,7 @@ module Homebrew return if ENV["CI"] || ENV["JENKINS_HOME"] branch = coretap_path.git_branch - return if branch.nil? || branch =~ %r{master} + return if branch.nil? || branch =~ /master/ <<-EOS.undent From a8ca47d294d1399393c4f066e0bebd356d500148 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 1 Oct 2017 19:07:10 +0100 Subject: [PATCH 6/6] diagnostic: remove unnecessary blank line. --- Library/Homebrew/diagnostic.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 29d2e342f7..065f042408 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -791,7 +791,6 @@ module Homebrew branch = coretap_path.git_branch return if branch.nil? || branch =~ /master/ - <<-EOS.undent Homebrew/homebrew-core is not on the master branch