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

Fix Toast messages showing a successful message after failed remote command #5105

Merged
merged 4 commits into from
Dec 15, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Dec 12, 2023

Demo

Screen.Recording.2023-12-13.at.11.47.19.AM.mov

Fixes #5095

@julieg18 julieg18 added the bug Something isn't working label Dec 12, 2023
@julieg18 julieg18 self-assigned this Dec 12, 2023
@julieg18 julieg18 changed the title Fix Toast messages showing a successfull message after failed remote command Fix Toast messages showing a successful message after failed remote command Dec 12, 2023
@@ -21,6 +24,28 @@ export class DvcConfig extends DvcCli {
return this.executeSafeProcess(cwd, Command.REMOTE, ...args)
}

public remoteAdd(cwd: string, ...args: Args) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 7 locations. Consider refactoring.

return this.executeDvcProcess(cwd, Command.REMOTE, SubCommand.ADD, ...args)
}

public remoteRename(cwd: string, ...args: Args) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 7 locations. Consider refactoring.

)
}

public remoteModify(cwd: string, ...args: Args) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 7 locations. Consider refactoring.

@@ -21,6 +24,28 @@ export class DvcConfig extends DvcCli {
return this.executeSafeProcess(cwd, Command.REMOTE, ...args)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executeSafeProcess catches the error, stopping the external command code from showing the error toast and allowing the Toast.showOutput used in setup/index.ts to get undefined (aka Operation successful).

I've fixed that by adding functions for adding and modifying the remote that don't catch the error thrown.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any other commands we need to move off safe process?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Remote list commands are run periodically and remote remove commands are guaranteed to almost always fail since we run them twice in different scopes.

Flag.PROJECT,
remote
)
} catch {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we don't need these try/catch blocks since executeSafeProcess already catches errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a test to ensure remote catches errors.

@julieg18 julieg18 marked this pull request as ready for review December 13, 2023 17:57
})

describe('remoteModifyUrl', () => {
it('should call createProcess with the correct parameters to modify a remote in the config', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[C] might want to state "url" in this description.

@julieg18 julieg18 enabled auto-merge (squash) December 15, 2023 14:43
Copy link

codeclimate bot commented Dec 15, 2023

Code Climate has analyzed commit 0ed1cf2 and detected 3 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 3

The test coverage on the diff in this pull request is 100.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.2% (0.0% change).

View more on Code Climate.

@julieg18 julieg18 merged commit 0e6c5be into main Dec 15, 2023
@julieg18 julieg18 deleted the add-error-toasts-to-remote-commands branch December 15, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error is not handled in remote add operation in non DVC repo
3 participants