Skip to content

Commit

Permalink
#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 4765b3b
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 72 deletions.
2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/addasset/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/close/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/create/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/discard/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/open/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/publish/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/azure/gitreleasemanager/setup/bundle.js

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions dist/azure/gitversion/execute/bundle.js

Large diffs are not rendered by default.

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
41 changes: 28 additions & 13 deletions dist/azure/gitversion/setup/bundle.js

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions dist/github/gitversion/execute/bundle.js

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions dist/github/gitversion/setup/bundle.js

Large diffs are not rendered by default.

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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"node": ">=20.0.0"
},
"scripts": {
"build": "npm run build:mock && npm run build:azure && npm run build:github",
"build": "npm run build:agent:mock && npm run build:agent:azure && npm run build:agent:github",
"format": "prettier --write src/**/*.ts",
"format-check": "prettier --check src/**/*.ts",
"build:agent:mock": "webpack --config webpack.config.js --env agent=mock",
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
5 changes: 5 additions & 0 deletions src/tools/gitversion/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class GitVersionSettingsProvider extends SettingsProvider implements IGit
public getGitVersionSettings(): GitVersionSettings {
const targetPath = this.buildAgent.getInput(ExecuteFields.targetPath)

const disableCache = this.buildAgent.getBooleanInput(ExecuteFields.disableCache)
const disableNormalization = this.buildAgent.getBooleanInput(ExecuteFields.disableNormalization)

const useConfigFile = this.buildAgent.getBooleanInput(ExecuteFields.useConfigFile)
const configFilePath = this.buildAgent.getInput(ExecuteFields.configFilePath)

Expand All @@ -25,6 +28,8 @@ export class GitVersionSettingsProvider extends SettingsProvider implements IGit

return {
targetPath,
disableCache,
disableNormalization,
useConfigFile,
configFilePath,
updateAssemblyInfo,
Expand Down
45 changes: 33 additions & 12 deletions src/tools/gitversion/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ISetupSettings } from '../common/models'

export interface IGitVersionTool extends IDotnetTool {
install(setupSettings: ISetupSettings): Promise<void>

run(options: GitVersionSettings): Promise<IExecResult>

writeGitVersionToAgent(gitversion: GitVersionOutput): void
}

Expand All @@ -22,16 +24,17 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
}

public run(options: GitVersionSettings): Promise<IExecResult> {
const workDir = this.getRepoDir(options.targetPath)
const workDir = this.getRepoDir(options)

const args = this.getArguments(workDir, options)

return this.execute('dotnet-gitversion', args)
}

private getRepoDir(targetPath: string): string {
private getRepoDir(options: GitVersionSettings): string {
const targetPath = options.targetPath
const srcDir = options.srcDir || '.'
let workDir: string
const srcDir = this.buildAgent.getSourceDir() || '.'
if (!targetPath) {
workDir = srcDir
} else {
Expand All @@ -47,7 +50,24 @@ 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 (disableCache) {
args.push('/nocache')
}

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

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

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

Expand Down Expand Up @@ -93,14 +114,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 +131,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 4765b3b

Please sign in to comment.