✨ Use env sha for build:wait when there's a project with no commit #1008
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.
What is this?
With the
build:wait
command, a project and commit can be provided to search for a build to wait on. However, sometimes theHEAD
commit, or even local CI environment variables, can refer to a merge commit instead of the branch commit. When a build is created, we use the correct commit in most environments. However when a user provides a commit to thebuild:wait
command, it might not match the commit that was used when creating the build. This causes the API to return an empty list since there are no builds associated with that commit for a project.This PR addresses this issue in two primary ways. First, the command will log
Waiting for build...
when the API returns an empty list. This is because this command can be started before a build is actually created, and will update with the correct info once a matching build is found within the command timeout. An error will be thrown if a build is not found within the timeout. Second, rather than relying on the user to provide the correct commit, we can default to the commit found in the environment, which is the same commit that would be used when creating a new build. This default commit is only used when providing the--project
flag without a--commit
flag.