-
-
Notifications
You must be signed in to change notification settings - Fork 378
loosen tag restriction to allow all non-whitespace, after the first char #3961
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
loosen tag restriction to allow all non-whitespace, after the first char #3961
Conversation
|
it looks like the test are failing on some python stuff: this works fine on my python. Looks like this was made to work in 3.13.6. I'll dumb it down presently. |
de3108a to
6a15239
Compare
|
ok, ready. |
djmitche
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.
This looks good! Please update task(1) to document this, where it describes the +tag|-tag syntax.
Please also make a corresponding update to https://github.com/GothenburgBitFactory/tw.org/blob/master/content/docs/tags.md and anywhere else you see fit in the docs.
Finally, Taskchampion will need updated to correspond -- see https://github.com/GothenburgBitFactory/taskchampion/blob/main/src/task/tag.rs#L8.
|
@djmitche so howcome the existing rust code doesn't reject the non-conformant tags coming from taskwarrior? There were no complaints from the storage backend with the C++ patch applied... that rust code you linked looks like it's supposed to bomb if the tag contains dashes. |
|
I wondered the same thing! The short answer is, that particular code isn't used by Taskwarrior -- Taskwarrior just gets key/value maps from TaskChampion and does whatever it wants with them. The slightly longer answer is that TaskChampion treats any key/value map as valid and won't bomb, but would just ignore invalid tags. So even if someone had tags with characters in them that TC didn't like, and was interoperating with another tool using TC directly, nothing would explode -- they just wouldn't see those tags in the TC-based tool. |
…rst char This opens up the rest of the word after the first char to be pretty much anything, in line with GothenburgBitFactory/taskwarrior#3961 and then we also add/adapt some more tests.
…rst char This opens up the rest of the word after the first char to be pretty much anything, in line with GothenburgBitFactory/taskwarrior#3961 and then we also add/adapt some more tests.
6e6f981 to
80fd258
Compare
…GothenburgBitFactory#3957) Instead of walking the string and stopping at the first non-isIdentifier() character (see Lexer::isIdentifierStart(), isIdentifierNext() and isSingleCharOperator()), walk all the way to the end of the word. This allows even punctuation and other characters to be used in tags. We still need to use isIdentifierStart() for the first character, to disambiguate it from a negative number or subtraction. Apparently there is no command context available, so the parser cannot "know" whether it's doing a "task calc" and have different parse rules. The lexing seems to happen before breaking the arguments down into commands for dispatch.
2b071f1 to
1895950
Compare
|
interesting so rather than gate the commit, the pre-commit action does an auto-fixup commit for formatting? I'm supposed to run the hooks on my side before pushing to pre-test this locally right? |
That's right. It's an advantage for more one-off PRs where someone might make a minor fix but not be willing to do a second round to fix the formatting. And, yes, |
djmitche
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.
Thanks!!
|
|
||
| .ig | ||
| see also taskwarrior:src/Lexer.cpp isSingleCharOperator() | ||
| see also taskchampion:src/task/task.rs INVALID_TAG_CHARACTERS |
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.
👍🏼
|
My vote would go for blocking the commit rather than surreptitiously fixing it. I think anyone would do whatever the project requires, if a formatter is required they just need to know. Blocking it in the test actions would serve that purpose. I only learned it happened accidentally but yet have no objections to enforced style. Well, good to know for next time.... |
|
Let's see how it goes. Let me know if it really starts to get annoying! |
This patch allows tags to be any non-whitespace characters, excepting the first char, which still must be an "identifier" character (see
Lexer::isIdentifier()), in particular so that "task calc" works with negative numbers and subtraction. Apparently CLI2 doesn't know the command yet when doing the parse, so it has the same rules for every command.I tried to get this to work on tags with spaces (for parity with Timewarrior), but could not get it working before I ran out of time to spend on this. That will have to be left as a future endeavor. I don't personally use spaces.
In the meantime, at least tags with dashes work now, and tags can also use utf8 chars, including as the first/only character, if they wish.
The patch includes a few extra tests using tags with dashes and glyphs.
Note: I did not test sync.
Fixes #3957