-
Notifications
You must be signed in to change notification settings - Fork 1
Add --error-on-diff flag to get an exit code 2 when there were diffs generated #47
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
Conversation
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.
Pull request overview
This PR adds a new --error-on-diff flag to the generate command that allows users to receive a non-zero exit code (exit code 2) when diff statements are generated, while maintaining backward compatibility by defaulting to exit code 0 when diffs are detected.
Changes:
- Added
ErrDiffDetectederror to signal when diff statements are generated - Implemented
--error-on-diffflag in the generate command - Modified main.go to handle the new error and exit with code 2 when the flag is enabled
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| main.go | Adds error handling logic to check for ErrDiffDetected and exit with code 2 if --error-on-diff flag is set |
| cmd/generate.go | Defines ErrDiffDetected, adds --error-on-diff flag, and returns the error when diff statements are generated in both stdout and file modes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a306240 to
b1d43f6
Compare
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b1d43f6 to
ca4b04c
Compare
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.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
cmd/generate.go:207
- When
--devmode is combined with--error-on-diff, the continuous loop will log the error but continue running. This behavior may be confusing because the exit code 2 error is treated as a soft error in dev mode, but as a hard error otherwise. Consider documenting this behavior or adding validation to prevent using both flags together if this combination doesn't make sense for the use case.
if dev {
for {
time.Sleep(time.Millisecond * 100)
err = continuousFunc()
if err != nil {
log.Printf("Failed to run: %v\n", err)
}
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
provokateurin
left a comment
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.
Cool, builtin git diff --exit-code 😛
cmd/init.go
Outdated
| _, err = runWithFile( | ||
| ctx, config, wd, tmpDir, migrationsDir, filepath.Join(migrationsDir, "001_init.up.sql"), 1, false) |
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.
Put each argument on a new line. Weird that gofmt doesn't do/enforce this already 🤔
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.
Done!
ca4b04c to
a3ae571
Compare
No description provided.