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

When running upgrade command, ignore errors upgrading sources if outside of a git repository #1196

Merged
merged 4 commits into from
Nov 21, 2024

Conversation

noahd1
Copy link
Member

@noahd1 noahd1 commented Nov 21, 2024

If you run the qlty upgrade command outside of a git directory it currently will perform the upgrade but then raise the following error:

❌ This subcommand must be run within a Git repository.

Turns out this is because it is attempting to update sources, and updating sources requires being inside of a Git repository.

This PR prevents error propagation in this case, allowing source updating to occur within a Git repository, and otherwise allows the upgrade to complete successfully without an error message.

@noahd1 noahd1 requested a review from lsegal November 21, 2024 00:38
@brynary
Copy link
Member

brynary commented Nov 21, 2024

@noahd1 the source upgrade behavior is valuable, so I think we need to account for that.

When run outside of of an initialized project, we should just update the CLI. When run inside of an initialized project, we should perform the current behavior to upgrade the CLI and then upgrade the sources

@lsegal
Copy link
Member

lsegal commented Nov 21, 2024

Would it be sufficient to just use the following? Not sure if this will generate garbage in logs or not.

let _ = SourceUpgrade::new().run();

@brynary
Copy link
Member

brynary commented Nov 21, 2024

@lsegal I think you may be right... @noahd1 it would be worth testing.

One small tweak, rather than the let _ = ... syntax, this would be more Rust idiomatic: SourceUpgrade::new().run().ok()

@noahd1 noahd1 changed the title Do not run source upgrade (if upgrading CLI) When running upgrade command, ignore errors upgrading sources if outside of a git repository Nov 21, 2024
@noahd1
Copy link
Member Author

noahd1 commented Nov 21, 2024

Tried it. It works. 5 character addition FTW.

Updated the title and the description to more properly reflect the decided upon solution.

@noahd1 noahd1 merged commit 0e61c67 into main Nov 21, 2024
11 checks passed
@noahd1 noahd1 deleted the nd-source-upgrade branch November 21, 2024 01:40
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

Successfully merging this pull request may close these issues.

3 participants