Skip to content

Commit

Permalink
fix(core): handle file change conflicts between sync generators
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Aug 29, 2024
1 parent 81acded commit 9fdc29d
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 73 deletions.
66 changes: 66 additions & 0 deletions packages/nx/src/daemon/server/sync-generators.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import type { SyncGeneratorChangesResult } from '../../utils/sync-generators';
import { _getConflictingGeneratorGroups } from './sync-generators';

describe('_getConflictingGeneratorGroups', () => {
it('should return grouped conflicting generators', () => {
const results: SyncGeneratorChangesResult[] = [
{
generatorName: 'a',
changes: [
{ type: 'UPDATE', path: 'file1.txt', content: Buffer.from('') },
{ type: 'UPDATE', path: 'file2.txt', content: Buffer.from('') },
{ type: 'UPDATE', path: 'file3.txt', content: Buffer.from('') },
],
},
{
generatorName: 'b',
changes: [
{ type: 'UPDATE', path: 'file1.txt', content: Buffer.from('') },
],
},
{
generatorName: 'c',
changes: [
{ type: 'UPDATE', path: 'file3.txt', content: Buffer.from('') },
{ type: 'UPDATE', path: 'file4.txt', content: Buffer.from('') },
],
},
{
generatorName: 'd',
changes: [
{ type: 'UPDATE', path: 'file5.txt', content: Buffer.from('') },
],
},
{
generatorName: 'e',
changes: [
{ type: 'UPDATE', path: 'file4.txt', content: Buffer.from('') },
{ type: 'UPDATE', path: 'file6.txt', content: Buffer.from('') },
],
},
{
generatorName: 'f',
changes: [
{ type: 'UPDATE', path: 'file7.txt', content: Buffer.from('') },
],
},
{
generatorName: 'g',
changes: [
{ type: 'UPDATE', path: 'file7.txt', content: Buffer.from('') },
],
},
{
generatorName: 'h',
changes: [
{ type: 'UPDATE', path: 'file8.txt', content: Buffer.from('') },
],
},
];

expect(_getConflictingGeneratorGroups(results)).toStrictEqual([
['a', 'b', 'c', 'e'],
['f', 'g'],
]);
});
});
Loading

0 comments on commit 9fdc29d

Please sign in to comment.