diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 41335cbe62..f7eef01068 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -80,6 +80,13 @@ module GitHub ["admin", "write"].include?(permission(repo, user)["permission"]) end + def branch_exists?(user, repo, branch) + API.open_rest("#{API_URL}/repos/#{user}/#{repo}/branches/#{branch}") + true + rescue API::HTTPNotFoundError + false + end + def pull_requests(repo, **options) url = "#{API_URL}/repos/#{repo}/pulls?#{URI.encode_www_form(options)}" API.open_rest(url)