Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pull_sha return value when no pull request #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zygzagZ
Copy link

@zygzagZ zygzagZ commented Sep 29, 2022

Pronto::Formatter::GithubStatusFormatter does not work outside of pull requests (pronto run throws an error), because Pronto::Github#create_commit_status retrieves sha by sha = pull_sha || status.sha, and pull_sha either returns pull's sha (if the pull exists) or throws an error.

This PR fixes it.

Pronto::Github#pull throws error when the PR cannot be found, thus pull[:head][:sha] if pull makes no sense (it exists or throws)

I fix this by catching Pronto::Error and returning nil. The error is thrown when PR cannot be found in Pronto::GithubPull#pull_by_id, Pronto::GithubPull#pull_by_branch or Pronto::GithubPull#pull_by_commit.

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.
@zygzagZ zygzagZ requested a review from a team as a code owner September 29, 2022 13:08
@ashkulz
Copy link
Member

ashkulz commented Sep 29, 2022

@zygzagZ can you add a test for this as well?

@ashkulz
Copy link
Member

ashkulz commented Dec 31, 2022

Any update, @zygzagZ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants