-
Notifications
You must be signed in to change notification settings - Fork 102
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
fix: fixed bug in old parser when using the defaults #200
Conversation
src/metadata-registry/forceIgnore.ts
Outdated
@@ -81,7 +80,7 @@ export class ForceIgnore { | |||
denies = this.parser.ignores(relativePath); | |||
fctResult = this.gitignoreParser.denies(relativePath); | |||
// send to look for differences, analytics | |||
this.resolveConflict(denies, fctResult, this.contents); | |||
this.resolveConflict(denies, fctResult, this.contents, relativePath); |
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.
If it's an instance var you don't have to pass it to a method that has access to that instance var.
If we're passing the relativePath here then we don't need to do the relative path resolution in resolveConflict
src/metadata-registry/forceIgnore.ts
Outdated
@@ -150,7 +150,7 @@ export class ForceIgnore { | |||
// send analytics, if they exist. | |||
Lifecycle.getInstance().emit('telemetry', { | |||
eventName: 'FORCE_IGNORE_DIFFERENCE', | |||
content: this.contents, | |||
content, | |||
oldLibraryResults, | |||
newLibraryResults, | |||
ignoreLines: this.ignoreLines, |
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.ignoreLines
will always be the entire contents of the forceignore file. don't we want this to only report the specific rules that caused the conflict?
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.
it was only the entries which caused issues... I renamed the variable to be more clear about what it is
src/metadata-registry/forceIgnore.ts
Outdated
@@ -122,6 +121,7 @@ export class ForceIgnore { | |||
private resolveConflict( | |||
newLibraryResults: boolean, | |||
oldLibraryResults: boolean, | |||
content: string, | |||
file: string |
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.
newLibraryResults
and oldLibraryResults
are very clear. content
and file
aren't. The content arg doesn't seem necessary since it's always this.contents
. Can we name those so it's clearer? E.g., forceignoreContents (if you keep it) and sourceFilePath?
Revert these files please:
|
src/metadata-registry/forceIgnore.ts
Outdated
// only show the warning once, it could come from denies() or accepts() | ||
warn = false; | ||
process.emitWarning( | ||
"The .forceignore file doesn't adhere to .gitignore format which will be the default behavior starting in Spring '21 release. More information on .gitignore format here: https://git-scm.com/docs/gitignore. Fix the following lines in your .forceignore and add '# .forceignore v2' to your .forceignore file to switch to the new behavior." | ||
"The .forceignore sourceFilePath doesn't adhere to .gitignore format which will be the default behavior starting in Spring '21 release. More information on .gitignore format here: https://git-scm.com/docs/gitignore. Fix the following lines in your .forceignore and add '# .forceignore v2' to your .forceignore sourceFilePath to switch to the new behavior." |
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 this say sourceFilePath
?
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.
yeah, I refactored a variable name and it didn't work correctly... look at all of the files I changed ( even though I didn't add them to my commit ) I'm going back through everything to make sure it's as it should be
src/metadata-registry/forceIgnore.ts
Outdated
): void { | ||
const ignoreItems = this.contents.split('\n'); | ||
const troubledIgnoreLines: string[] = []; |
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.
Use a Set<string>
for troubledIgnoreLines
and on line 136 use has
instead of includes
so we don't have to iterate through the whole list each time to test for membership.
src/metadata-registry/forceIgnore.ts
Outdated
@@ -122,29 +120,28 @@ export class ForceIgnore { | |||
private resolveConflict( | |||
newLibraryResults: boolean, | |||
oldLibraryResults: boolean, | |||
file: string | |||
sourceFilePath: string |
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.
nit: fsPath
has somewhat been a codebase convention for "file path" if you're looking to rename this, nbd though.
'**/package2-descriptor.json', | ||
'**/package2-manifest.json', | ||
], | ||
ignoreLines: [testPattern], | ||
file, | ||
}; | ||
|
||
const telemetrySpy = env.spy(Lifecycle.prototype, 'emit'); | ||
// @ts-ignore call the private method directly to avoid excessive stubbing |
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.
Out of curiosity, what would need to be excessively stubbed?
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.
At this point it might not require a lot of stubbing
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.
If not much is needed then forceIgnore.accept
or forceIgnore.deny
is preferred over forceIgnore.resolveConflict(true, false, file)
src/metadata-registry/forceIgnore.ts
Outdated
@@ -153,8 +156,8 @@ export class ForceIgnore { | |||
content: this.contents, | |||
oldLibraryResults, | |||
newLibraryResults, | |||
ignoreLines: this.ignoreLines, | |||
file, | |||
ignoreLines, |
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.
Can remove 147-151 and use this instead - easy way to convert an iterable to array.
ignoreLines, | |
ignoreLines: Array.from(troubledIgnoreLines), |
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.
BOOM 💥
changes were addressed and steve is out for the day.
* fix: The old parser had a bug when handling the new default values
* fix: The old parser had a bug when handling the new default values
* fix: The old parser had a bug when handling the new default values
What does this PR do?
the default ignore lines we use with the new parser had a bug with the old parser. Specifically the
**/*.dup*
was being exploded to ignore any item containing "dup" which for the metadata typeDuplicateRule
caused an issuefixed analytics to log the lines that caused the issue, and the file path
What issues does this PR fix or reference?
forcedotcom/cli#685
@W-8291520@
Functionality Before
<insert gif and/or summary>
Functionality After
<insert gif and/or summary>