Skip to content

Commit 0cbc542

Browse files
authored
cli: jetpack rsync's untracked files check should check packages too (#42006)
PR #41442 added messaging for when `jetpack rsync` is going to ignore a file because it hasn't been `git add`ed. But that PR only checked files directly in the plugin being synced, which is not terribly useful for mu-wpcom-plugin where everything happens in packages/jetpack-mu-wpcom. To fix this, for the check, look at any monorepo packages symlinked from `vendor/*/*` and `jetpack_vendor/*/*` too. Further recursion is not necessary, since Composer already hoists everything relevant.
1 parent 37ae14f commit 0cbc542

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

tools/cli/commands/rsync.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,42 @@ async function isFileExcluded( filePath ) {
464464
* @return {string} Files that aren't tracked.
465465
*/
466466
async function getUntrackedFiles( pluginPath ) {
467+
const paths = [ pluginPath ];
468+
469+
// Add any Composer-symlinked vendor packages. Assumes the usual directory structure.
470+
const cwd = await fs.realpath( process.cwd() );
471+
for ( const dir of [ 'vendor', 'jetpack_vendor' ] ) {
472+
const dirents = (
473+
await fs.readdir( path.join( pluginPath, dir ), { withFileTypes: true } ).catch( () => [] )
474+
).filter( e => e.isDirectory() );
475+
for ( const dir2 of dirents ) {
476+
const dirents2 = (
477+
await fs
478+
.readdir( path.join( dir2.parentPath, dir2.name ), { withFileTypes: true } )
479+
.catch( () => [] )
480+
).filter( e => e.isSymbolicLink() );
481+
for ( const link of dirents2 ) {
482+
try {
483+
const rp = path.relative(
484+
cwd,
485+
await fs.realpath( path.join( link.parentPath, link.name ) )
486+
);
487+
if ( ! rp.startsWith( '..' + path.sep ) ) {
488+
paths.push( rp );
489+
}
490+
} catch {
491+
// Probably a broken symlink. Ignore it.
492+
}
493+
}
494+
}
495+
}
496+
467497
try {
468498
const { stdout } = await execa( 'git', [
469499
'ls-files',
470500
'--others',
471501
'--exclude-standard',
472-
pluginPath,
502+
...paths,
473503
] );
474504
return stdout;
475505
} catch ( e ) {

0 commit comments

Comments
 (0)