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

Improve some more code #1892

Merged
merged 3 commits into from
Mar 27, 2022
Merged

Improve some more code #1892

merged 3 commits into from
Mar 27, 2022

Conversation

fb55
Copy link
Contributor

@fb55 fb55 commented Mar 22, 2022

Similar to #1889 — updates some code to make it more readable.

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("/"));
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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 in src.

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.

Copy link
Contributor Author

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("/"));
Copy link
Collaborator

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 in src.

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.

src/lib/output/themes/default/DefaultTheme.tsx Outdated Show resolved Hide resolved
src/lib/output/themes/lib.tsx Show resolved Hide resolved
fb55 and others added 2 commits March 26, 2022 22:14
@Gerrit0 Gerrit0 merged commit f766681 into TypeStrong:beta Mar 27, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 27, 2022

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

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