Skip to content

Commit

Permalink
check git history for .cls files instead of .cls-meta.xml (#903)
Browse files Browse the repository at this point in the history
* check git history for .cls files instead of .cls-meta.xml

* Look first for not-xml file, then for xml file

* changelog

---------

Co-authored-by: Nicolas Vuillamy <[email protected]>
  • Loading branch information
k-capehart and nvuillam authored Nov 26, 2024
1 parent 0664b47 commit 4219e88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta`

## [5.8.1] 2024-11-26

- Fix [hardis:org:diagnose:unused-apex-classes](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-apex-classes/): Use .cls file, not cls-meta.xml file to get creation date from git

## [5.8.0] 2024-11-25

- New monitoring command [hardis:org:diagnose:unused-connected-apps](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-connected-apps/) to detect Connected Apps that are not used anymore and might be disabled or deleted.
Expand Down
19 changes: 12 additions & 7 deletions src/common/metadata-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,19 @@ Issue tracking: https://github.com/forcedotcom/cli/issues/2426`)
const metadataType = metadataTypes[0];

// Look for matching file in sources
const globExpression = `**/${metadataType.directoryName}/**/${packageXmlName}.${metadataType.suffix || ""}-meta.xml`;
const globExpressions = [
`**/${metadataType.directoryName}/**/${packageXmlName}.${metadataType.suffix || ""}`, // Works for not-xml files
`**/${metadataType.directoryName}/**/${packageXmlName}.${metadataType.suffix || ""}-meta.xml` // Works for all XML files
]
for (const packageDirectory of packageDirectories) {
const sourceFiles = await glob(globExpression, {
cwd: packageDirectory.fullPath,
});
if (sourceFiles.length > 0) {
const metaFile = path.join(packageDirectory.path, sourceFiles[0]);
return metaFile;
for (const globExpression of globExpressions) {
const sourceFiles = await glob(globExpression, {
cwd: packageDirectory.fullPath,
});
if (sourceFiles.length > 0) {
const metaFile = path.join(packageDirectory.path, sourceFiles[0]);
return metaFile;
}
}
}
return null;
Expand Down

0 comments on commit 4219e88

Please sign in to comment.