8000 feat: Added disclaimer for branch checkout by dds05 · Pull Request #8957 · dolthub/dolt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Added disclaimer for branch checkout #8957

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dds05
Copy link
Contributor
@dds05 dds05 commented Mar 7, 2025

To fix #6876

Copy link
Contributor
@timsehn timsehn left a comment

Choose a reason for hiding this comment

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

This needs to be a bit more robust.

Also we need a BATS test in:

https://github.com/dolthub/dolt/blob/main/integration-tests/bats/sql-checkout.bats

Some of those tests will need to be updated because we use dolt sql -q "call dolt_checkout('-b', ...)" a bunch of places.

@@ -176,6 +178,10 @@ func doDoltCheckout(ctx *sql.Context, args []string) (statusCode int, successMes
if err != nil {
return 1, "", err
}
terminal_command:=strings.Join(os_args, " ")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to be a bit more clever here. I think we need to check and make sure that call dolt_checkout() with the -b option is the only sql statement being run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timsehn
Okay but what if the user calls the command like dolt sql --q "call dolt_checkout('myBranch2');" i.e. without the -b option.
I believe this also needs to be handled.

Copy link
Contributor
@macneale4 macneale4 left a comment

Choose a reason for hiding this comment

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

The stored procedure can't return color escape codes in its warning (or any other message) since ORMs and other tools don't consistently handle them correctly. Remember that this is an programming interface :-)

I assume you want the terminal experience to show the warning, and in color? That should all be handled either in the CLI commands or in the sql shell.

@macneale4
Copy link
Contributor

A possible better first step would be: #8875

@dds05
Copy link
Contributor Author
dds05 commented Mar 19, 2025

@macneale4 So should I remove the color from :-
cli.PrintErrln(color.YellowString("WARNING: The checked out branch is only changed for this current session."))

@macneale4
926D
Copy link
Contributor

No, I think the approach doesn't fit with the way the application works. For example 'os.Args[1:]' should definitely not be used anywhere close to the sql engine. There are many layers between where the command line arguments are parsed and the procedure code. And in the case of CLI commands, they are generally in separate processes. The command line is connecting to a server in some cases.

I think a better plan it to surface warnings by default in dolt sql, then we can return a warning via the standard sql message channel and surface it to the user. See #8875

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn users about running dolt sql -q "call dolt_checkout(...);"
4 participants
0