fix(affected): handle Github Actions provided commit not part of checkout #9214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #9208
With #9169 we started using
GITHUB_BASE_REF
to determine the base of our--affected
comparison. This can return a commit that doesn't exist in the current checkout, but will passrev-parse
since the reference exists.This PR avoids crashing by treating
bad object
git errors the same asno merge base
so if we get passed a commit that is valid, but non-existent in the checkout we still run.Testing Instructions
I only have a manual test as creating a repository where a commit exists according to
rev-parse
, but not as part of the checkout is beyond my git-fu levels.Create a shallow checkout:
git clone git@github.com:vercel/turborepo.git --depth=1
Find a commit that exists in the repo, but does not exist in the checkout e.g.
ce11d86705632160dd234ec4cf04bb1bd4ddeebc
Verify that
turbo ls --affected
crashes with "bad object" message:Test PR and verify that since we can't diff the commit we assume everything has changed: