From 3387a7ada40db585823ac96f9551ccdac9ae7993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chary=C5=82o?= Date: Thu, 29 Sep 2022 15:03:14 +0200 Subject: [PATCH] fix: pull_sha return value when no pull request Pronto::Github#pull throws error when the PR cannot be found, thus `pull[:head][:sha] if pull` makes no sense (it exists or throws) We fix this by catching Pronto::Error (thrown when PR cannot be found in Pronto::GithubPull#pull_by_id, Pronto::GithubPull#pull_by_branch or Pronto::GithubPull#pull_by_commit) and return nil. --- lib/pronto/github.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pronto/github.rb b/lib/pronto/github.rb index 72b6cef2..e8b1aa6a 100644 --- a/lib/pronto/github.rb +++ b/lib/pronto/github.rb @@ -102,6 +102,8 @@ def pull_id def pull_sha pull[:head][:sha] if pull + rescue Pronto::Error + nil end def pull