Skip to content

Commit

Permalink
Merge pull request #12952 from issyl0/github-branch-exists
Browse files Browse the repository at this point in the history
utils/github: Add a `branch_exists?` method
  • Loading branch information
issyl0 committed Mar 5, 2022
2 parents 3d689eb + 8463259 commit 67512ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Library/Homebrew/utils/github.rb
Expand Up @@ -80,6 +80,13 @@ def write_access?(repo, user = nil)
["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)
Expand Down

0 comments on commit 67512ae

Please sign in to comment.