-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Show human-readable git errors #8152
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Motivation Now and then `swift build` throws a GitShellError which doesn't have details about what was an issue and with which dependency. ### Modification GitShellError now conforms to CustomStringConvertible protocol which makes it printable. ### Result `swift build` now shows the error output from the git command instead of showing an error code when GitShellError is thrown.
… git repo. ### Motivation isValidDirectory is called before a repo URL is established, and before a context to throw a meaningful error is established. The errors that are thrown are not useful to humans. ### Modification This change supresses the GitShellError errors and allows to establish a context for more meaningful GitCloneError errors. ### Result Before the change: > error: GitShellError: fatal: cannot change to '/Users/yy/Library/Caches/org.swift.swiftpm/repositories/postgres-kit-e4358808': No such file or directory After the change: > error: Failed to clone repository https://github.com/vapor/postgres-kit.git: > Cloning into bare repository '/Users/yy/work/pub/tst/testpackage/.build/repositories/postgres-kit-e4358808'... > fatal: unable to access 'https://github.com/vapor/postgres-kit.git/': Could not resolve host: github.com
MaxDesiatov
reviewed
Dec 3, 2024
dschaefer2
requested changes
Dec 3, 2024
Revert "Do not throw an error from isValidDirectory if the directory is not a git repo." This reverts commit 1a5db35. `isValidDirectory` is a public API and we should avoid changing behavior, since external code might depend on raised exception for the flow when the target directory isn't a git repo or when git itself isn't available.
GitShelError can be thrown in public `isValidDirectory`, make the error public too, so it can be caught.
Git command might be helpful to reproduce access issues, let's include it in the description of GitShelError.
MaxDesiatov
reviewed
Dec 4, 2024
The exception has been private prior to 301fa08. There's not yet usecase where public is necessary, let's keep it package until we do have a usecase.
@swift-ci test |
bripeticca
requested changes
Dec 4, 2024
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.
LGTM, just noticed a few typos 😄
bkhouri
approved these changes
Dec 4, 2024
bripeticca
reviewed
Dec 4, 2024
weissi
reviewed
Dec 4, 2024
XCTAssertThrowsError and inspecting the error is more accurate assert than catching the exception ourselves. Previous version: test passes if the error isn't raised Current version: test fails if the error isn't raised.
@swift-ci test |
MaxDesiatov
reviewed
Dec 5, 2024
MaxDesiatov
reviewed
Dec 5, 2024
@swift-ci please test |
@swift-ci please test windows |
dschaefer2
approved these changes
Dec 5, 2024
bripeticca
approved these changes
Dec 5, 2024
@swift-ci test |
@swift-ci test windows |
xedin
approved these changes
Dec 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Show human-readable git errors
Motivation:
I noticed that when swiftpm cache is empty and there's a network issue, then
swift build
throws an error which is not helpful, something like this:where it does say "output" but doesn't actually include output or show any details about what dependency caused the error.
Modifications:
GitShellError
now conforms to CustomStringConvertible protocol, so that when it is thrown then it will print what was the git errorGitShelError
has now package access to allow catching it explicitly.Result:
Errors now tell details of the failure: