From 48c0c673f85c2e511db635b8ec52ce74f4d87fab Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 18 Dec 2020 13:21:06 +0000 Subject: [PATCH] Fix GitHub search behaviour change Handle the case where paths are now returned with preceding `/`. --- Library/Homebrew/utils/github.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 7a73c695f3..7b2596b325 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -312,7 +312,14 @@ module GitHub end def search_code(**qualifiers) - search("code", **qualifiers) + matches = search("code", **qualifiers) + return matches if matches.blank? + + matches.map do |match| + # .sub workaround for GitHub returning preceding / + match["path"] = match["path"].sub(%r{^/}, "") + match + end end def issues_for_formula(name, tap: CoreTap.instance, tap_full_name: tap.full_name, state: nil)