Skip to content

Commit

Permalink
fix: fix file move debug
Browse files Browse the repository at this point in the history
  • Loading branch information
iowillhoit committed May 13, 2024
1 parent f986a1b commit e7d0591
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/shared/localShadowRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,12 @@ export class ShadowRepo {
}

this.logger.debug(
['Files have moved. Committing moved files:', ...matches.entries()]
.map(([add, del]) => `File ${add} was moved to ${del}`)
.join('\n')
[
'Files have moved. Committing moved files:',
[...matches.entries()].map(([del, add]) => `- File ${add} was moved to ${del}`).join(os.EOL),
].join(os.EOL)
);

movedFilesMarker?.addDetails({ filesMoved: matches.size });

// Commit the moved files and refresh the status
Expand Down
9 changes: 8 additions & 1 deletion test/unit/localDetectMovedFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('local detect moved files', () => {
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));
fs.mkdirSync(path.join(projectDir, 'force-app', 'new'), { recursive: true });
fs.writeFileSync(path.join(projectDir, 'force-app', 'CustomLabels.labels-meta.xml'), '<xml></xml>');
fs.writeFileSync(path.join(projectDir, 'force-app', 'CustomLabelsTwo.labels-meta.xml'), '<xml></xml>');

const shadowRepo: ShadowRepo = await ShadowRepo.getInstance({
orgId: '00D456789012345',
Expand All @@ -47,7 +48,8 @@ describe('local detect moved files', () => {

// Manually commit this first file
const labelsFile = path.join('force-app', 'CustomLabels.labels-meta.xml');
const sha = await shadowRepo.commitChanges({ deployedFiles: [labelsFile] });
const labelsFileTwo = path.join('force-app', 'CustomLabelsTwo.labels-meta.xml');
const sha = await shadowRepo.commitChanges({ deployedFiles: [labelsFile, labelsFileTwo] });
expect(sha).to.not.be.empty;
expect(gitAdd.calledOnce).to.be.true;

Expand All @@ -56,6 +58,11 @@ describe('local detect moved files', () => {
path.join(projectDir, labelsFile),
path.join(projectDir, 'force-app', 'new', 'CustomLabels.labels-meta.xml')
);

fs.renameSync(
path.join(projectDir, labelsFileTwo),
path.join(projectDir, 'force-app', 'new', 'CustomLabelsTwo.labels-meta.xml')
);
await shadowRepo.getStatus(true);

// Moved file should have been detected and committed
Expand Down

0 comments on commit e7d0591

Please sign in to comment.