-
Notifications
You must be signed in to change notification settings - Fork 712
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
Improve some more code #1892
Improve some more code #1892
Conversation
Similar to TypeStrong#1889 — improves some code to make it more readable.
@@ -279,7 +277,7 @@ export class SourceLinkPlugin extends ConverterComponent { | |||
// No repository found, add path to ignored paths | |||
const segments = dirName.split("/"); | |||
for (let i = segments.length; i > 0; i--) { | |||
this.ignoredPaths.push(segments.slice(0, i).join("/")); | |||
this.ignoredPaths.add(segments.slice(0, i).join("/")); |
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.
Without a set, this could add sub-paths multiple times.
@Gerrit0 My understanding of this is that this would always ignore the entire path if a single file is ignored. Eg. if src/components/generated
is in the .gitignore
, this would ignore everything in src
. I suspect that we'd rather just add the directory by itself, and not the path leading up to it.
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.
In other words, we might want to move this loop to the top of the function — the dirName
should probably be checked if any part of it is ignored.
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 would always ignore the entire path if a single file is ignored. Eg. if
src/components/generated
is in the .gitignore, this would ignore everything insrc
.
I read this the same way, and I agree, this definitely looks wrong. I'm surprised there haven't been any bug reports about it.
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've added a fix for this issue.
@@ -279,7 +277,7 @@ export class SourceLinkPlugin extends ConverterComponent { | |||
// No repository found, add path to ignored paths | |||
const segments = dirName.split("/"); | |||
for (let i = segments.length; i > 0; i--) { | |||
this.ignoredPaths.push(segments.slice(0, i).join("/")); | |||
this.ignoredPaths.add(segments.slice(0, i).join("/")); |
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 would always ignore the entire path if a single file is ignored. Eg. if
src/components/generated
is in the .gitignore, this would ignore everything insrc
.
I read this the same way, and I agree, this definitely looks wrong. I'm surprised there haven't been any bug reports about it.
Co-authored-by: Gerrit Birkeland <gerrit@gerritbirkeland.com>
Thanks! It'll be interesting to see if anyone notices differences from the source link plugin. Given that the previous broken behavior never got reported... I kind of suspect nobody will |
Similar to #1889 — updates some code to make it more readable.