From 791614d0e43d8c0d2934f5ea4c7d48f8afc68dc3 Mon Sep 17 00:00:00 2001 From: Artur Date: Sat, 2 Mar 2024 23:05:17 +0100 Subject: [PATCH] #1051 - implemented `nocache` and `nonormalize` --- dist/azure/gitversion/execute/task.json | 16 ++++++++++++++ gitversion/execute/action.yml | 8 +++++++ src/tools/gitversion/models.ts | 4 ++++ src/tools/gitversion/tool.ts | 28 +++++++++++++++++-------- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/dist/azure/gitversion/execute/task.json b/dist/azure/gitversion/execute/task.json index a6465f749..fe7398e92 100644 --- a/dist/azure/gitversion/execute/task.json +++ b/dist/azure/gitversion/execute/task.json @@ -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", diff --git a/gitversion/execute/action.yml b/gitversion/execute/action.yml index 985f27e2d..f3aa492a8 100644 --- a/gitversion/execute/action.yml +++ b/gitversion/execute/action.yml @@ -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 diff --git a/src/tools/gitversion/models.ts b/src/tools/gitversion/models.ts index f58fa8d0e..07b6b78fd 100644 --- a/src/tools/gitversion/models.ts +++ b/src/tools/gitversion/models.ts @@ -2,6 +2,8 @@ import { ISettingsProvider } from '../common/models' export enum ExecuteFields { targetPath = 'targetPath', + disableCache = 'disableCache', + disableNormalization = 'disableNormalization', useConfigFile = 'useConfigFile', configFilePath = 'configFilePath', updateAssemblyInfo = 'updateAssemblyInfo', @@ -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 diff --git a/src/tools/gitversion/tool.ts b/src/tools/gitversion/tool.ts index 646147812..327176b15 100644 --- a/src/tools/gitversion/tool.ts +++ b/src/tools/gitversion/tool.ts @@ -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)) { @@ -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') @@ -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 += '\\' @@ -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) {