-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Dashes and colons #191
Dashes and colons #191
Conversation
Hey @adiabatic! Thanks for working on this (I know jumping into a foreign codebase isn't easy!) and for all of your thoughtfulness in how to incorporate the change well and have good test coverage. In general I think your code looks good! Regarding the test coverage you mention, I agree that it's important to test the 1-to-0 tags case (and would probably be good to test that with a tag that has some characters in it), which I think we can do by adding more people to the The other way to test this would be to define a custom As you mentioned, I do think it would be good to have tests to make sure that tags don't start or end with punctuation, and don't have multiple dashes or colons in a row (unless you can think of a reason why that would be a good feature to have?). Another thing that should probably be tested is that we can use dashes and colons in tags on the command line without Bash or other shells doing weird interpretations of them (I'm happy to explain more if that doesn't make sense). For instance, the initial implementation of tags used
(where One small note on the code you have: I think your regex might have a bug in it. Using Rubular it looks like it doesn't correctly find
Basically: an alphanumeric character, followed by 0 or more sets of "optional punctuation followed by alphanumeric character." This seems to work for everything I can throw at it, and guarantees that tags start and end with an alphanumeric. So one last thing this has made me think about is whether it makes sense for colons in tags to have some amount of meaning. Like
If you think that makes sense to do, we could talk about:
Thoughts? |
Hi - sorry to drop in on you. I've been ignoring these messages for awhile, but you guys keep accidentally tagging me in your PRs and issues! :) I'm @science - I'm not actually sure if "\" backslashes will escape the @ references in your code citations.. (It doesn't look like it in this post: @science). Possibly |
So sorry for all the noise, @science! We'll try to be more careful about backticks from now on! 😬 |
I'll restore the tags for the preexisting people and add in a couple more regulars so we can test both 1->0 and 2->1 cases. Stan and Norm sound like good candidates to me.
Oh, that. Yeah. I do some journaling with Day One, and trying to remember what I had to escape gave me a headache. Eventually I gave up and just started typing Theoretically Colons and hyphens don't seem like problems for
Ooh, good catch. The thing is,
but isn't with
In the off chance that some user somewhere is already using tags that start with a number, I think
is the better option.
I'd very much like this too, but it's too much work for me right now and is best shoved off to another PR to be done at a later date. I'll happily tag things with coloned hierarchies, but I probably won't be needing filtering facilities like this for years.
That makes complete sense to me. Also, let's see if this auto-links: @JacobEvelyn. I put a ZWNJ between the at-sign and the username, so that should be a way to not accidentally tag people when we type out tags. In the next PR: Updated, documented TAG_REGEX and tests that don't clobber the things we were testing previously. |
Hey @adiabatic! Thanks for all the thoughtful discussion.
Sounds perfect.
Agreed!
I'm not totally sure I follow. For avoiding shell interpretation of special characters, what you describe with
They seem to work for me in
Whoops, yes! I had been playing around with
Agreed that this should be a separate PR. I've made #192 for tracking that feature. Thanks for the feedback on that! Lastly, thanks as well for (a) teaching me you can add titles to Markdown links here (yep, I noticed that 😄), and (b) informing me that Agricola has a successor! Let me know when you've pushed changes to the PR and I'll take a look! |
Hey @adiabatic! Anything I can do to help you with this? |
Thanks, but not really. Just been swamped with other things. I plan on finishing it up in a week or two. |
Oops. Didn't notice that option. I'm having trouble getting Git to do what I want. Some of my pushes to the dashes-and-colons branch might be buggy, including the most recent one (dc2015c). |
7c85dbe is a revision actually worth discussing. |
@adiabatic just skimmed it and the code looks pretty good to me! When you said "I plan on finishing it up in a week or two" does that mean there's something more you planned to add, or is this potentially good to go? (Seems fine to me but I want to make sure I'm not missing something.) |
I think I'm 95% of the way there, but there's one more thing I'd like to test. Remember how we said "we don't want "@food: ate an eight-pound hamburger with Stan" to parse the tag as "food:", but rather "food"? Where should I put a "run |
Good question @adiabatic, and sorry for the slow response! Agreed that we should have that test, but I think there are actually two parts to it. One part is the "does this get interpreted correctly when we call So I guess that's a roundabout way of saying that I think testing it in
Does that make sense? |
No worries about the slow pace. I'm in no rush. I guess that makes for three things that deserve testing, AFAICT:
Shouldn't we have tricky cases in both CONTENT and SCRAMBLED_CONTENT, and not just in a couple tests' |
Thanks for the thoughts. Here's what I'm thinking:
I thought we needed a test for this at first, but now I'm realizing that when you add an activity or note there really isn't any "interpretation" of the tag that happens, so I don't think there would be anything to test here. (The line that gets added to
Yep, we need to test this. I'd also vote for putting both colons and dashes in our tag if possible.
This is what I was trying to say around this being good to test but since we apparently don't have any tests for any of the coloring (i.e. of friends or locations) I think we should save this for another PR and not worry about lumping it in to this one.
I'm happy either way. As long as we're testing the behavior I don't think it matters if it's in just one test or if the behavior is happening in a bunch via Also, one last thing I'm thinking of: we should update the Does all of that make sense? |
Makes sense. I'll update the README if everything I've done here so far looks OK, or is at least on the right track. |
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.
@adiabatic this looks really good to me! Just a few tiny comments (let me know if you can't see them—I've never used GitHub's PR review system before and could be doing something wrong 😬) but this is pretty much good to go.
The only other thing is adding one or two examples of this to the README. Would you be willing to add that into your next commit?
@@ -3,5 +3,5 @@ | |||
require "friends/version" | |||
|
|||
module Friends | |||
TAG_REGEX = /@\p{Alnum}+/ | |||
TAG_REGEX = /(?<!\p{Alnum})@\p{Alnum}(?:[:-]?\p{Alnum})*/ |
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.
Ah, smart move with the negative lookbehind at the beginning. Technically this could inadvertently catch some false positives like very weird emails (example.@example.com
) but that's so edge-casey I don't think we should worry about it. It's definitely better than before!
end | ||
end | ||
|
||
describe "when friend already has tags" do | ||
let(:friend_name) { "Marie" } | ||
let(:tag) { "school:ecole-normale-superieure" } |
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.
Very minor, but would you mind adding the French accents here? (school:école-normale-supérieure
) I think Ruby/the shell/the regex should all handle those characters fine but it would be nice to have it in a test.
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.
Should we do that, though? If we encourage non-7-bit-ASCII tags, we ought to do some sort of normalization. I had a look at the wikipedia page on the subject, looked at NFD, NFC, NFKD, and NFKC and the best method I have at hand for picking the best normalization form for our purposes is eenie-meenie-miney-moe.
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.
I don't feel strongly here so I'll defer to you. Thanks for doing so much digging on this!
@@ -77,6 +77,7 @@ | |||
let(:cleaned_edited_content) do | |||
<<-EXPECTED_CONTENT | |||
### Activities: | |||
- 2018-02-06: @science:indoors:agronomy-with-hydroponics: **Norman Borlaug** and **George Washington Carver** scored a tour of _Atlantis_' hydroponics gardens through wetplants@example.org and they took me along. |
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.
Fun example! 😄
@@ -41,13 +41,24 @@ | |||
let(:tag) { "science" } | |||
|
|||
it "removes tag from friend" do | |||
line_changed "- Marie Curie [Atlantis] @science", "- Marie Curie [Atlantis]" | |||
line_changed "- Marie Curie [Atlantis] @science", |
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.
Is this just a stylistic change or am I missing something subtle here?
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.
Looks stylistic to me. I started breaking lines defensively to avoid rubocop
's warnings.
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.
Plus, it's easier to see what's changed if everything lines up vertically.
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.
Works for me! 👍
@@ -35,7 +35,8 @@ | |||
end | |||
|
|||
it "updates existing location" do | |||
line_changed "- Marie Curie [Atlantis] @science", "- Marie Curie [Paris] @science" | |||
line_changed "- Marie Curie [Atlantis] @science", |
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.
Same question here on what's changed.
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.
Still stylistic.
@@ -3,5 +3,5 @@ | |||
require "friends/version" | |||
|
|||
module Friends | |||
TAG_REGEX = /@\p{Alnum}+/ | |||
TAG_REGEX = /(?<!\p{Alnum})@\p{Alnum}(?:[:-]?\p{Alnum})*/ |
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.
One small thing I'm wondering here though... is it weird that tags match case-sensitively? Should @games:caverna
and @games:Caverna
really be different?
(To be clear, I had been wondering this already—it's nothing to do with your changes—and I'm happy to make that change in a separate PR. More just curious for your thoughts.)
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.
Exact-byte-match (bolstered by a strong convention of all-lowercase tags) is certainly the easiest thing to do, and more complicated things aren't a Pareto improvement (an improvement that makes at least one person better off and nobody worse off). I could imagine someone using @nice for "this was a nice thing that happened" and @Nice for "something concerning this one city in the southeast of France", or something else that differs only by capitalization.
I'd say "don't do any of this until someone asks for it", but it's worth thinking about these things as a group, although implementing one doesn't necessarily mean you're obliged to implement them all:
- case-insensitive tag matching (but case-preserving, like HFS+, APFS, and NTFS file names)
- ensuring that all strings are folded into one particular normalization form (Ruby might do this properly itself; I don't know.)
- diacritic-insensitive matching, at least for some locales
Nobody's asking for any of this AFAIK, so I'd personally hesitate to implement any of these features if friends
were my project.
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.
Wow, thanks for such a thoughtful response. Yeah I guess I buy the argument that it's fine to leave these for now until someone needs them to behave otherwise.
Thanks so much, @adiabatic! Sorry for the delay; I've had an unexpectedly busy week but I know firsthand how annoying it can be to wait for a maintainer to look at your code so sorry again! I left you a "PR review" but let me know if you can't see my comments or have any questions. In general this looks really good! Just one or two small tweaks and then the README! Thanks for all the hard work and patience! |
@adiabatic would you prefer that I clean this up and do the finishing touches so we can get this out? Up to you! |
Sorry 'bout the eight-day pause. I think it's good to go. |
Awesome, this all looks fantastic. (And no worries about the delay.) Thanks so much for your thoughtfulness with everything. Would you be down to squash all of this into a single commit with some reasonable commit message? Something like the following is fine, but feel free to write more if you want!
(The I'm also more than happy to do the squash (you'd still be listed as the author in |
I could use the practice. I'll squash it myself. |
Thanks so much for all the hard work, @adiabatic! This is an awesome improvement. This feature is now released in v0.37 ( You rock. |
This is a preliminary PR. I'm not totally sure it's the one I want, but I wanted to get feedback on it, mostly on the tests. I'd be happy to squash my commits into a single commit once it's all ready to go.
There aren't any specific tests to ensure that lines like "@food:molecular-gastronomy: ate a giant hamburger that was actually 100% jelly" don't parse the tag as "food:molecular-gastronomy:". I'll add those tests.
What's gnawing at the back of my mind is that I changed the tags on people in the sample data, and this impacts what the tests actually test. Before, tests ensured that going from 1 tag to 0 was OK. Now, tests ensure that going from 2 tags to 1 work as expected. We could add more people to the sample data and test both 2 to 1 and 1 to 0, but I'd have trouble choosing suitable sample friends in keeping with the preexisting theme you've got going. I could bring in Marie's husband Pierre, but I wouldn't know who else fits the theme you've got going.
If I change the preexisting tags like "@science" to something like "@science:indoor" (IIRC neither Curie nor Hopper did fieldwork like John Muir) and update the tests to match, would that give us the coverage we want?
Hi there! Thanks so much for submitting a pull request!
Let's just make sure together that all of these boxes are checked before we
merge this change:
README.md
file is updated as appropriate.Don't worry—this list will get checked off in no time!