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

Allow OSCommand.Quote to be invoked within a custom command #2193

Merged

Conversation

Ryooooooga
Copy link
Contributor

@Ryooooooga Ryooooooga commented Sep 30, 2022

  • PR Description

There are many situations where we will want to use Quote.

customCommands:
    command: git commit -m {{.Form.message | Quote}}
  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go run scripts/cheatsheet/main.go generate)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • Docs (specifically docs/Config.md) have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

Copy link
Owner

@jesseduffield jesseduffield left a comment

Choose a reason for hiding this comment

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

Great idea! Could we add a test for this? Either a unit test or integration test

@Ryooooooga Ryooooooga force-pushed the feature/template-funcs branch from b21c2ab to e16f1ba Compare October 1, 2022 11:55
@Ryooooooga
Copy link
Contributor Author

add simple test case using existing integration test.

@@ -37,7 +37,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
{
Name: "bar",
Description: "Bar",
Value: "BAR",
Value: `"BAR"`,
Copy link
Owner

Choose a reason for hiding this comment

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

Why are we quoting this? Shouldn't we not have quotes in the value so that we can ensure that it's properly quoted by the quote function?

Copy link
Contributor Author

@Ryooooooga Ryooooooga Oct 2, 2022

Choose a reason for hiding this comment

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

This is testing to be escaped " itself. Without | Quote, only BAR is output even if value is `"BAR"`.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah I see: we need the quotes in the value so that when call the quote function the quotes are escaped and end up in the diff. Okay that makes sense!

Copy link
Owner

@jesseduffield jesseduffield left a comment

Choose a reason for hiding this comment

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

one question :)

@jesseduffield jesseduffield merged commit 8a022dd into jesseduffield:master Oct 2, 2022
@Ryooooooga Ryooooooga deleted the feature/template-funcs branch October 3, 2022 22:44
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.

2 participants