Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/adt-flow/src/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { basename } from 'node:path';

Check notice on line 1 in packages/adt-flow/src/service.ts

View check run for this annotation

CodeScene Access / CodeScene Code Health Review (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 4.32 to 4.29, threshold = 4 This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
import type {
TransportSourceManifest,
TransportSourceManifestEntry,
Expand Down Expand Up @@ -242,11 +242,18 @@
);
}

const ACTIVE_VERSION_ID = '00000';

function isMutableVersion(versionId: string): boolean {
Comment thread
ThePlenkov marked this conversation as resolved.
return versionId === ACTIVE_VERSION_ID;
}
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

function descriptorSelectionMatches(
descriptor: ObjectDescriptor,
component: string,
version: SourceVersionRef,
): boolean {
if (isMutableVersion(version.id)) return false;
Comment thread
ThePlenkov marked this conversation as resolved.
return descriptor.selections.some(
(selection) =>
selection.component === component &&
Expand Down Expand Up @@ -368,7 +375,10 @@
if (
!descriptor ||
descriptor.configDigest !== configDigest ||
descriptor.formatDigest !== formatDigest
descriptor.formatDigest !== formatDigest ||
descriptor.selections.some((selection) =>
isMutableVersion(selection.versionId),
)
) {
return undefined;
}
Expand Down
83 changes: 83 additions & 0 deletions packages/adt-flow/tests/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,89 @@ describe('transport checkout', () => {
).toBe('source indexed\n');
});

it('re-reads an indexed active 00000 head instead of reusing it', async () => {
const workspace = await root();
let current = manifest(
'modified',
version('before'),
version('00000'),
'DEVK900001',
);
const ports = dependencies(() => current);
let liveSource = 'source first\n';
ports.readSource.mockImplementation(async () => liveSource);
const flow = createAdtFlowService(ports);
await flow.checkout({
root: workspace,
transports: ['DEVK900001'],
config,
});
ports.readSource.mockClear();
ports.loadObject.mockClear();
liveSource = 'source second\n';
current = manifest(
'modified',
version('before'),
version('00000'),
'DEVK900002',
);

const result = await flow.checkout({
root: workspace,
transports: ['DEVK900002'],
config,
});

expect(result.fastPath).toBe('none');
expect(result.sapCalls).toEqual({ manifest: 1, metadata: 1, source: 1 });
expect(ports.loadObject).toHaveBeenCalledTimes(1);
expect(result.changed).toEqual(['src/feature/zcl_sample.clas.abap']);
expect(
await readFile(
join(workspace, 'src/feature/zcl_sample.clas.abap'),
'utf8',
),
).toBe('source second\n');
});

it('does not repeat an active 00000 head through the exact-head fast path', async () => {
const workspace = await root();
const ports = dependencies(() =>
manifest('modified', version('before'), version('00000')),
);
let liveSource = 'source first\n';
ports.readSource.mockImplementation(async () => liveSource);
const flow = createAdtFlowService(ports);
await flow.checkout({
root: workspace,
transports: ['DEVK900001'],
config,
});

const unchanged = await flow.checkout({
root: workspace,
transports: ['DEVK900001'],
config,
});
expect(unchanged.fastPath).toBe('none');
expect(unchanged.changed).toEqual([]);

liveSource = 'source second\n';
const changed = await flow.checkout({
root: workspace,
transports: ['DEVK900001'],
config,
});
expect(changed.fastPath).toBe('none');
expect(changed.changed).toEqual(['src/feature/zcl_sample.clas.abap']);
expect(
await readFile(
join(workspace, 'src/feature/zcl_sample.clas.abap'),
'utf8',
),
).toBe('source second\n');
});

it('preserves an indexed object as the base of a later parent-attributed task', async () => {
const workspace = await root();
let current = manifest(
Expand Down
Loading