Skip to content

Commit

Permalink
Add support for dot-delimited GitVersion outputs/variables
Browse files Browse the repository at this point in the history
Expanded the tool to set dot-delimited (`GitVersion.Property`) outputs and variables alongside existing formats. Updated corresponding tests to validate the new format for both outputs and environment variables, ensuring consistency and proper coverage.
  • Loading branch information
arturcic committed Dec 10, 2024
1 parent c18c731 commit 39f0917
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/tools/gitversion/runner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ describe('GitVersion Runner', () => {
expect(getEnv('GitVersion_Major')).toBeDefined()
expect(getEnv('GitVersion_Minor')).toBeDefined()
expect(getEnv('GitVersion_Patch')).toBeDefined()
expect(getEnv('GitVersion.Major')).toBeDefined()
expect(getEnv('GitVersion.Minor')).toBeDefined()
expect(getEnv('GitVersion.Patch')).toBeDefined()

expect(getEnv('major')).toBeDefined()
expect(getEnv('minor')).toBeDefined()
Expand Down
12 changes: 12 additions & 0 deletions src/__tests__/tools/gitversion/tool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ describe('GitVersionTool', () => {
expect(outputs.get('GitVersion_SemVer')).toBe('1.2.3-alpha.1')
expect(outputs.get('GitVersion_FullSemVer')).toBe('1.2.3-alpha.1')

expect(outputs.get('GitVersion.Major')).toBe('1')
expect(outputs.get('GitVersion.Minor')).toBe('2')
expect(outputs.get('GitVersion.Patch')).toBe('3')
expect(outputs.get('GitVersion.SemVer')).toBe('1.2.3-alpha.1')
expect(outputs.get('GitVersion.FullSemVer')).toBe('1.2.3-alpha.1')

expect(variables.get('major')).toBe('1')
expect(variables.get('minor')).toBe('2')
expect(variables.get('patch')).toBe('3')
Expand All @@ -97,6 +103,12 @@ describe('GitVersionTool', () => {
expect(variables.get('GitVersion_Patch')).toBe('3')
expect(variables.get('GitVersion_SemVer')).toBe('1.2.3-alpha.1')
expect(variables.get('GitVersion_FullSemVer')).toBe('1.2.3-alpha.1')

expect(variables.get('GitVersion.Major')).toBe('1')
expect(variables.get('GitVersion.Minor')).toBe('2')
expect(variables.get('GitVersion.Patch')).toBe('3')
expect(variables.get('GitVersion.SemVer')).toBe('1.2.3-alpha.1')
expect(variables.get('GitVersion.FullSemVer')).toBe('1.2.3-alpha.1')
})
})

Expand Down
2 changes: 2 additions & 0 deletions src/tools/gitversion/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ export class GitVersionTool extends DotnetTool {
}
this.buildAgent.setOutput(name, value)
this.buildAgent.setOutput(`GitVersion_${property}`, value)
this.buildAgent.setOutput(`GitVersion.${property}`, value)
this.buildAgent.setVariable(name, value)
this.buildAgent.setVariable(`GitVersion_${property}`, value)
this.buildAgent.setVariable(`GitVersion.${property}`, value)
} catch (_error) {
this.buildAgent.error(`Unable to set output/variable for ${property}`)
}
Expand Down

0 comments on commit 39f0917

Please sign in to comment.