Skip to content
Open
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
7 changes: 6 additions & 1 deletion lib/ModuleDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export class ModuleDeclaration {
*/
public ref?: string

/**
* A git tag (also stored in ref for checkout, kept to render :tag in toText)
*/
public tag?: string

/**
* Comments from the Puppetfile
*/
Expand Down Expand Up @@ -104,7 +109,7 @@ export class ModuleDeclaration {
if (':ref' in parameters) {
this.ref = parameters[':ref']
} else if (':tag' in parameters) {
this.ref = parameters[':tag']
this.ref = this.tag = parameters[':tag']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only set this.tag here and not this.ref because it makes no sense to set it here IMHO

}
this.forgeModule = false
await this.fetchGitMetadata()
Expand Down
4 changes: 3 additions & 1 deletion lib/PuppetFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ export class PuppetFile {
# {{{this}}}
{{/each}}
mod '{{author}}-{{name}}',
:git => '{{git}}'{{#if ref}},
:git => '{{git}}'{{#if tag}},
:tag => '{{tag}}'{{else if ref}},
:ref => '{{ref}}'{{/if}}
{{#unless @last}}

Expand Down Expand Up @@ -227,6 +228,7 @@ mod '{{author}}-{{name}}', '{{version}}'{{#unless @last}}
git: value.git,
comments: value.comments,
ref: '',
tag: value.tag ?? '',
}
if (value.ref) {
retValue['ref'] = value.ref
Expand Down
22 changes: 22 additions & 0 deletions test/puppetfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ mod 'test-default2', '1.2.3'

## dependencies

mod 'test-dependency', '1.2.4'`

const subject = await new PuppetFile().fromText(puppetfile)

expect(subject.toText()).toEqual(puppetfile)
})

it('should keep :tag when generating the puppet file text', async () => {
const puppetfile = `forge 'http://localhost:${sb.getPort()}'

# Git modules

mod 'test-git',
:git => '${tmpDir.path}',
:tag => 'test'

# Forge modules

mod 'test-default', '1.2.3'

## dependencies

mod 'test-dependency', '1.2.4'`

const subject = await new PuppetFile().fromText(puppetfile)
Expand Down
Loading