Repository navigation
build(TreeDiffer): don't assume that rootPaths to dirty check are imm… #2053
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,10 @@ export class TreeDiffer { | |
| private rootDirName: string; | ||
| private include: RegExp = null; | ||
| private exclude: RegExp = null; | ||
| private rootPath: string = null; | ||
|
|
||
| constructor(private rootPath: string, includeExtensions?: string[], | ||
| constructor(includeExtensions?: string[], | ||
| excludeExtensions?: string[]) { | ||
| this.rootDirName = path.basename(rootPath); | ||
|
|
||
| let buildRegexp = (arr) => new RegExp(`(${arr.reduce(combine, "")})$`, "i"); | ||
|
|
||
| this.include = (includeExtensions || []).length ? buildRegexp(includeExtensions) : null; | ||
|
|
@@ -39,7 +38,9 @@ export class TreeDiffer { | |
| } | ||
|
|
||
|
|
||
| public diffTree(): DiffResult { | ||
| public diffTree(rootPath): DiffResult { | ||
| this.rootPath = rootPath; | ||
| this.rootDirName = path.basename(rootPath); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a problem here: fingerprints still contain old absolute paths, so fingerprints basically need a reset (or alternatively, the fingerprints object keys need to be the relative path rather than absolute)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should be a relative path
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For posteriority: I must have had a subtle error when trying the relativePath stuff before, it seems to work correctly now (so virtualPath is not needed) --- updating the pr |
||
| let result = new DirtyCheckingDiffResult(this.rootDirName); | ||
| this.dirtyCheckPath(this.rootPath, result); | ||
| this.detectDeletionsAndUpdateFingerprints(result); | ||
|
|
||
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.
So, if I understand this, broccoli sometimes changes the inputPath for us, and we need to be able to propagate that change to the TreeDiffer, and we do that here by passing it in here, right?
But, (some) plugins still think they need to use the old inputPath, they don't have any idea that it 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.
looks like it to me. my patch is failing in some cases so I need to investigate it further. initial explorations showed that the output path for certain plugins like replace and mergeTrees was not immutable.
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.
Have you thought about something like this?
https://github.com/IgorMinar/angular/pull/1/files working example (tested with test.unit.tools and test.unit.cjs)
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 did think about that, but it is simply wrong that the input path changes. The plugin should be the owner of the
inputPathstate and nobody else should change it, otherwise the whole system is unstable and it's easy to make assumptions that the input path doesn't change and cache absolute paths somewhere.I have a different PR in works that stabilizes the input path.
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.
The contracts for these properties are pseudo-documented in the broccolijs codebase, but it's not clear how strong those contracts are.