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
15 changes: 15 additions & 0 deletions src/shared/__tests__/lockfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ describe('lockfile', () => {
expect(b.build().generatedAt).not.toBe('2026-01-01T00:00:00.000Z');
});

it('stamps the current generator only when a pin changes (#310)', () => {
const initial: Lockfile = {
...emptyLockfile(),
generator: 'capa@2.2.0',
skills: [sampleSkill],
};
const unchanged = new LockfileBuilder(initial);
unchanged.upsertSkill(sampleSkill);
expect(unchanged.build().generator).toBe('capa@2.2.0');

const added = new LockfileBuilder(initial);
added.upsertSkill({ ...sampleSkill, id: 'new-skill' });
expect(added.build().generator).toBe(emptyLockfile().generator);
});

it('starts empty when given null', () => {
const b = new LockfileBuilder(null);
const lf = b.build();
Expand Down
4 changes: 3 additions & 1 deletion src/shared/lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,13 @@ export class LockfileBuilder {
? { providerConfig: sortProviderConfig(this.providerConfig) }
: {}),
};
// Only bump generatedAt when pins/generator actually changed.
// Only restamp generator/generatedAt when the pins changed, so a no-op
// install after a capa upgrade leaves the lockfile untouched.
if (
this.initialSemanticKey === null ||
lockfileSemanticKey(lockfile) !== this.initialSemanticKey
) {
lockfile.generator = `capa@${VERSION}`;
lockfile.generatedAt = new Date().toISOString();
}
return lockfile;
Expand Down
Loading