This commit is contained in:
Artur Stolear
2020-02-03 19:31:31 +02:00
parent 5021e6bca9
commit 237764149f
2 changed files with 15 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ import { IBuildAgent, IDotnetTool, IExecResult, TYPES } from "./common";
import { injectable, inject } from "inversify"; import { injectable, inject } from "inversify";
import path = require("path"); import path = require("path");
export interface IGitVersionOptions { export interface IGitVersionArguments {
targetPath: string; targetPath: string;
useConfigFile: boolean; useConfigFile: boolean;
configFilePath: string; configFilePath: string;
@@ -12,7 +12,7 @@ export interface IGitVersionOptions {
srcDir: string; srcDir: string;
} }
export const RunOptions = { export const GitVersionRunOptions = {
targetPath: "targetPath", targetPath: "targetPath",
useConfigFile: "useConfigFile", useConfigFile: "useConfigFile",
@@ -59,9 +59,9 @@ export interface IGitVersion {
export interface IGitVersionTool { export interface IGitVersionTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>; install(versionSpec: string, includePrerelease: boolean): Promise<void>;
run(options: IGitVersionOptions): Promise<IExecResult>; run(options: IGitVersionArguments): Promise<IExecResult>;
writeGitVersionToAgent(gitversion: IGitVersion): void; writeGitVersionToAgent(gitversion: IGitVersion): void;
getGitVersionOptions(): IGitVersionOptions; getGitVersionOptions(): IGitVersionArguments;
} }
@injectable() @injectable()
@@ -82,7 +82,7 @@ export class GitVersionTool implements IGitVersionTool {
await this.dotnetTool.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease); await this.dotnetTool.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
} }
public run(options: IGitVersionOptions): Promise<IExecResult> { public run(options: IGitVersionArguments): Promise<IExecResult> {
const workDir = this.getRepoDir(options.targetPath); const workDir = this.getRepoDir(options.targetPath);
const args = this.getArguments(workDir, options); const args = this.getArguments(workDir, options);
@@ -105,7 +105,7 @@ export class GitVersionTool implements IGitVersionTool {
return workDir.replace(/\\/g, "/"); return workDir.replace(/\\/g, "/");
} }
private getArguments(workDir: string, options: IGitVersionOptions): string[] { private getArguments(workDir: string, options: IGitVersionArguments): string[] {
const args = [ const args = [
workDir, workDir,
"/output", "/output",
@@ -140,17 +140,17 @@ export class GitVersionTool implements IGitVersionTool {
return args; return args;
} }
public getGitVersionOptions(): IGitVersionOptions { public getGitVersionOptions(): IGitVersionArguments {
const targetPath = this.buildAgent.getInput(RunOptions.targetPath); const targetPath = this.buildAgent.getInput(GitVersionRunOptions.targetPath);
const useConfigFile = this.buildAgent.getBooleanInput(RunOptions.useConfigFile); const useConfigFile = this.buildAgent.getBooleanInput(GitVersionRunOptions.useConfigFile);
const configFilePath = this.buildAgent.getInput(RunOptions.configFilePath); const configFilePath = this.buildAgent.getInput(GitVersionRunOptions.configFilePath);
const updateAssemblyInfo = this.buildAgent.getBooleanInput(RunOptions.updateAssemblyInfo); const updateAssemblyInfo = this.buildAgent.getBooleanInput(GitVersionRunOptions.updateAssemblyInfo);
const updateAssemblyInfoFilename = this.buildAgent.getInput(RunOptions.updateAssemblyInfoFilename); const updateAssemblyInfoFilename = this.buildAgent.getInput(GitVersionRunOptions.updateAssemblyInfoFilename);
const additionalArguments = this.buildAgent.getInput(RunOptions.additionalArguments); const additionalArguments = this.buildAgent.getInput(GitVersionRunOptions.additionalArguments);
const srcDir = this.buildAgent.getSourceDir().replace(/\\/g, "/"); const srcDir = this.buildAgent.getSourceDir().replace(/\\/g, "/");

View File

@@ -1,5 +1,5 @@
import { container, IBuildAgent, TYPES, SetupOptions } from "../../core/common"; import { container, IBuildAgent, TYPES, SetupOptions } from "../../core/common";
import { IGitVersionTool, IGitVersionOptions, IGitVersion, GitVersionTool } from "../../core/gitversion"; import { IGitVersionTool, IGitVersionArguments, IGitVersion, GitVersionTool } from "../../core/gitversion";
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool); container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool);
@@ -24,7 +24,7 @@ export async function setup() {
export async function run() { export async function run() {
try { try {
const inputOptions: IGitVersionOptions = gitVersionTool.getGitVersionOptions(); const inputOptions: IGitVersionArguments = gitVersionTool.getGitVersionOptions();
const result = await gitVersionTool.run(inputOptions); const result = await gitVersionTool.run(inputOptions);