Skip to content

Commit

Permalink
GitTools#1051 - implemented nocache and nonormalize
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Mar 3, 2024
1 parent 5b09438 commit 791614d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
16 changes: 16 additions & 0 deletions dist/azure/gitversion/execute/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@
"helpMarkDown": "Optionally supply the path to the working directory",
"groupName": "gitversionDetails"
},
{
"name": "disableCache",
"type": "boolean",
"label": "Disable Cache",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to disable GitVersion cache"
},
{
"name": "disableNormalization",
"type": "boolean",
"label": "Disable Normalization",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether to disable GitVersion normalization"
},
{
"name": "useConfigFile",
"type": "boolean",
Expand Down
8 changes: 8 additions & 0 deletions gitversion/execute/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ inputs:
description: Optionally supply the path to the working directory
required: false
default: ''
disableCache:
description: Whether to disable GitVersion cache
required: false
default: 'false'
disableNormalization:
description: Whether to disable GitVersion normalization
required: false
default: 'false'
useConfigFile:
description: Whether to use a custom configuration file
required: false
Expand Down
4 changes: 4 additions & 0 deletions src/tools/gitversion/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ISettingsProvider } from '../common/models'

export enum ExecuteFields {
targetPath = 'targetPath',
disableCache = 'disableCache',
disableNormalization = 'disableNormalization',
useConfigFile = 'useConfigFile',
configFilePath = 'configFilePath',
updateAssemblyInfo = 'updateAssemblyInfo',
Expand All @@ -12,6 +14,8 @@ export enum ExecuteFields {

export interface GitVersionSettings {
[ExecuteFields.targetPath]: string
[ExecuteFields.disableCache]: boolean
[ExecuteFields.disableNormalization]: boolean
[ExecuteFields.useConfigFile]: boolean
[ExecuteFields.configFilePath]: string
[ExecuteFields.updateAssemblyInfo]: boolean
Expand Down
28 changes: 19 additions & 9 deletions src/tools/gitversion/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
private getArguments(workDir: string, options: GitVersionSettings): string[] {
let args = [workDir, '/output', 'json', '/output', 'buildserver']

const { useConfigFile, configFilePath, updateAssemblyInfo, updateAssemblyInfoFilename, additionalArguments } = options
const { useConfigFile, disableCache, disableNormalization, configFilePath, updateAssemblyInfo, updateAssemblyInfoFilename, additionalArguments } =
options

if (useConfigFile) {
if (this.buildAgent.isValidInputFile('configFilePath', configFilePath)) {
Expand All @@ -56,6 +57,15 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
throw new Error('GitVersion configuration file not found at ' + configFilePath)
}
}

if (disableCache) {
args.push('/nocache')
}

if (disableNormalization) {
args.push('/nonormalize')
}

if (updateAssemblyInfo) {
args.push('/updateassemblyinfo')

Expand Down Expand Up @@ -93,14 +103,14 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
}

private argStringToArray(argString: string): string[] {
var args: string[] = []
const args: string[] = []

var inQuotes = false
var escaped = false
var lastCharWasSpace = true
var arg = ''
let inQuotes = false
let escaped = false
let lastCharWasSpace = true
let arg = ''

var append = function (c: string) {
const append = function (c: string) {
// we only escape double quotes.
if (escaped && c !== '"') {
arg += '\\'
Expand All @@ -110,8 +120,8 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
escaped = false
}

for (var i = 0; i < argString.length; i++) {
var c = argString.charAt(i)
for (let i = 0; i < argString.length; i++) {
const c = argString.charAt(i)

if (c === ' ' && !inQuotes) {
if (!lastCharWasSpace) {
Expand Down

0 comments on commit 791614d

Please sign in to comment.