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

checkout doesn't report anything helpful when the requested reference is missing. #1683

Open
jsoref opened this issue Apr 16, 2024 · 0 comments

Comments

@jsoref
Copy link
Contributor

jsoref commented Apr 16, 2024

I've run across people / repositories where they have workflows that for varying reasons end up asking the checkout action (typically actions/checkout@v4) for a branch/tag/reference that doesn't exist:

If one uses git directly:

Cloning into 'checkout-missing-reference-0'...
warning: Could not find remote branch hello-world to clone.
fatal: Remote branch hello-world not found in upstream origin
Error: Process completed with exit code 128

If one uses actions/checkout@v4, one sees exit code 1 but this isn't particularly helpful:

Fetching the repository
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
The process '/usr/bin/git' failed with exit code 1
Waiting 15 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
The process '/usr/bin/git' failed with exit code 1
Waiting 20 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
Error: The process '/usr/bin/git' failed with exit code 1

Note that users are using actions/checkout@v4, they aren't using git ... fetch and there's no reason to expect end users to understand implementation details of git ... fetch -- that's why they're using actions/checkout@....

It is possible to improve the user experience -- consider these changes:

/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
The process '/usr/bin/git' failed with exit code 1
Waiting 10 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
The process '/usr/bin/git' failed with exit code 1
Waiting 14 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
/usr/bin/git -c protocol.version=2 ls-remote origin +refs/heads/hello-world*:refs/remotes/origin/hello-world* +refs/tags/hello-world*:refs/tags/hello-world*
Warning: No objects found matching refSpec +refs/heads/hello-world*:refs/remotes/origin/hello-world*,+refs/tags/hello-world*:refs/tags/hello-world* -- this is why checkout failed
Error: The process '/usr/bin/git' failed with exit code 1

https://github.com/check-spelling-sandbox/checkout-missing-reference-0/actions/runs/8694496977

image


Note: the error handling and reporting is much better when a repository doesn't exist.

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

No branches or pull requests

1 participant