runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.83k stars 1.06k forks source link

fix: update FileWorkspace logic to use pull request refs only when PR number is specified #4851

Open marcus-rev opened 3 months ago

marcus-rev commented 3 months ago

what

failed to build command: running git fetch origin pull/0/head:: fatal: couldn't find remote ref pull/0/head

will re-clone repo, could not determine if was at correct commit: git rev-parse HEAD^2: exit status 128: fatal: ambiguous argument 'HEAD^2': unknown revision or path not in the working tree.
updating project PR status%!(EXTRA *github.ErrorResponse=POST https://api.github.com/repos/<your-org>/<your-terraform-repo>/statuses/master: 422 Validation Failed [{Resource:Status Field:sha Code:custom Message:sha must be a 40 character SHA1}])...

why

tests

references

https://github.com/runatlantis/atlantis/blob/6fe0303279839faadb76e94de94d7c250876b336/runatlantis.io/docs/api-endpoints.md#post-apiplan

Should close #4850

X-Guardian commented 2 weeks ago

Thanks for this @marcus-rev. Can you add a unit test for this change, and confirm in the PR description that you have tested this in your own local environment.