-
Notifications
You must be signed in to change notification settings - Fork 131
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
Improve error messages for spago publish #1121
Conversation
test-fixtures/publish-no-git.txt
Outdated
Command failed with exit code 128: git status --porcelain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is considerably worse than the one we were giving out before - can we improve it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also update the Git.listTags
to use message
rather than shortMessage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think shortMessage
vs message
is going to matter here - the previous error message for the same test case was pretty informative:
❌ The git tree is not clean, or you haven't checked out the tag you want to publish.
Command failed with exit code 128: git status --porcelain
Please commit or stash your changes, and checkout the tag you want to publish.
fatal: not a git repository (or any of the parent directories): .git
To create the tag, you can run:
git tag v0.0.1
The current one (even with message
) much less so:
❌ Could not run `git status`. Error:
Command failed with exit code 128: git status --porcelain
fatal: not a git repository (or any of the parent directories): .git
I'd be pretty confused myself if I got this error.
It looks like we should catch the error where we have the context to give a good explanation, rather than just throwing the error that comes from git.
(to clarify - the old error message was not perfect either. We are still reporting the message that comes from git, but I think that's still confusing. The informative part of this is probably the only one we should show, and print the rest with debug logging: The git tree is not clean, or you haven't checked out the tag you want to publish.
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three things.
First, it's not clear to me why this test originally reported the above error. The "The git tree is not clean, or you haven't checked out the tag you want to publish.)" message is only reported when git status
succeeds. If git status
failed, it would just die there. So, what changes did I make that caused that to change?
Second, while I can mention the "git tree is not clean" part, checking out the tag shouldn't be done until the other issues are resolved first.
Third, printing the git status
error as a debug message (as I'm understanding your last sentence) seems erroneous, too. If git status
fails, there's a larger issue at hand (like the fact that no git repo exists) that should be reported to the user. Saying the 'git tree is not clean' misses the point. So, I updated the message to clarify why we were running git status
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all good, but I still think this warrants further investigation to improve error messages - I mean, we have a test that consistently reproduces a situation where a user gets a bad error message. We don't need to report that the user needs to make a tag at that point, but it should be clearly actionable, which it's not at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meaning... we should tell the user to run git init
in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git status
will return an exit code 128 in various situations (no git repository available, or it's there but it's owned by another user, etc), but the most common reason is by far "there's no git repo".
So we should figure out that a 128 was returned and tell the user "Spago could not run git status
because there's no git repo. Please run git init
and commit your source files to move forward" (or something like that). We don't need to report the error message coming from git, we are pretty sure of what's going on.
Description of the change
Fixes #1108.
These changes may still cause someone to run
spago publish
a few times before they fix every error, but it should prevent unpublishable git tags. The idea is:Git.pushTags
call, which requires login credentials to a step before the actual publishChecklist:
README
P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊