From 4b40c92baaa9dc1940d3b3e0b95bc0b755c505de Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 25 Nov 2026 17:51:07 +0100 Subject: [PATCH 1/2] fix(parser): accept :tag as an alias for :ref on git modules A Puppetfile line with `mod 'x-y', :git => '...', :tag => 'v1'` is valid r10k syntax, but the parser only knew about `:ref`. The `:tag` parameter was silently dropped, `this.ref` stayed undefined, and `fetchGitMetadata()` skipped the checkout step. metadata.json was then read from the repository's default branch instead of the tagged commit, which made the resolver pick up dependency ranges that the tag no longer carries. The only symptom was an unrelated-looking range conflict like `No possible version for requirement x => y (<9.0.0)`. Treat `:tag` as an alias for `:ref`; simpleGit's checkout handles tags, branches, and SHAs identically, so no other call site needs to change. --- lib/ModuleDeclaration.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ModuleDeclaration.ts b/lib/ModuleDeclaration.ts index d3e7f11..0b13d4a 100644 --- a/lib/ModuleDeclaration.ts +++ b/lib/ModuleDeclaration.ts @@ -103,6 +103,8 @@ export class ModuleDeclaration { this.git = parameters[':git'] if (':ref' in parameters) { this.ref = parameters[':ref'] + } else if (':tag' in parameters) { + this.ref = parameters[':tag'] } this.forgeModule = false await this.fetchGitMetadata() From 789ebadae9b2bd6afc8894bf8bfbb71f8007ff56 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 25 Nov 2026 17:51:13 +0100 Subject: [PATCH 2/2] test: cover :tag parsing for git modules in ModuleDeclaration --- test/module.declaration.test.ts | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/module.declaration.test.ts diff --git a/test/module.declaration.test.ts b/test/module.declaration.test.ts new file mode 100644 index 0000000..042c892 --- /dev/null +++ b/test/module.declaration.test.ts @@ -0,0 +1,38 @@ +import tmp from 'tmp-promise' +import simpleGit from 'simple-git' +import { writeFile } from 'fs/promises' +import path from 'path' +import { ModuleDeclaration } from '../lib/ModuleDeclaration' +import { expect } from '@jest/globals' + +jest.setTimeout(30000) + +describe('ModuleDeclaration.fromText', () => { + let tmpDir: tmp.DirectoryResult + + beforeEach(async () => { + tmpDir = await tmp.dir({ unsafeCleanup: true }) + const git = simpleGit(tmpDir.path, { + config: ['user.email=test@test.com', 'user.name=Tester', 'init.defaultBranch=main'], + }) + await git.init() + await writeFile( + path.join(tmpDir.path, 'metadata.json'), + '{"name":"test-tagged","version":"0.1.0","dependencies":[]}' + ) + await git.add(path.join(tmpDir.path, 'metadata.json')) + await git.commit('tagged release') + await git.addTag('v1.0.0') + }) + + afterEach(async () => { + await tmpDir.cleanup() + }) + + it('accepts :tag as an alias for :ref on a git-sourced module', async () => { + const declaration = await new ModuleDeclaration().fromText( + `mod 'test-tagged', :git => '${tmpDir.path}', :tag => 'v1.0.0'` + ) + expect(declaration.ref).toEqual('v1.0.0') + }) +})