minor
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
|
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
|
||||||
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/gitversion-tool";
|
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/gitversion-tool";
|
||||||
import { IGitVersionInput, IGitVersionOutput } from "../../tools/gitversion/models";
|
import { GitVersionInput, GitVersionOutput } from "../../tools/gitversion/models";
|
||||||
|
|
||||||
import container from "../../core/ioc";
|
import container from "../../core/ioc";
|
||||||
|
|
||||||
@@ -27,11 +27,11 @@ export async function setup() {
|
|||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const inputOptions: IGitVersionInput = gitVersionTool.getGitVersionOptions();
|
const inputOptions: GitVersionInput = gitVersionTool.getGitVersionInput();
|
||||||
|
|
||||||
const result = await gitVersionTool.run(inputOptions);
|
const result = await gitVersionTool.run(inputOptions);
|
||||||
|
|
||||||
const gitversion = JSON.parse(result.stdout) as IGitVersionOutput;
|
const gitversion = JSON.parse(result.stdout) as GitVersionOutput;
|
||||||
gitVersionTool.writeGitVersionToAgent(gitversion);
|
gitVersionTool.writeGitVersionToAgent(gitversion);
|
||||||
|
|
||||||
if (result.code === 0) {
|
if (result.code === 0) {
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import path = require("path");
|
|||||||
import { injectable, inject } from "inversify";
|
import { injectable, inject } from "inversify";
|
||||||
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
|
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
|
||||||
import { IDotnetTool } from "../../core/dotnet-tool";
|
import { IDotnetTool } from "../../core/dotnet-tool";
|
||||||
import { IGitVersionInput, IGitVersionOutput, GitVersionRunOptions } from "./models";
|
import { GitVersionInput, GitVersionOutput, GitVersionRunOptions } from "./models";
|
||||||
|
|
||||||
export interface IGitVersionTool {
|
export interface IGitVersionTool {
|
||||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||||
run(options: IGitVersionInput): Promise<IExecResult>;
|
run(options: GitVersionInput): Promise<IExecResult>;
|
||||||
writeGitVersionToAgent(gitversion: IGitVersionOutput): void;
|
writeGitVersionToAgent(gitversion: GitVersionOutput): void;
|
||||||
getGitVersionOptions(): IGitVersionInput;
|
getGitVersionInput(): GitVersionInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@@ -29,7 +29,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: IGitVersionInput): Promise<IExecResult> {
|
public run(options: GitVersionInput): 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);
|
||||||
@@ -52,7 +52,7 @@ export class GitVersionTool implements IGitVersionTool {
|
|||||||
return workDir.replace(/\\/g, "/");
|
return workDir.replace(/\\/g, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
private getArguments(workDir: string, options: IGitVersionInput): string[] {
|
private getArguments(workDir: string, options: GitVersionInput): string[] {
|
||||||
const args = [
|
const args = [
|
||||||
workDir,
|
workDir,
|
||||||
"/output",
|
"/output",
|
||||||
@@ -87,7 +87,7 @@ export class GitVersionTool implements IGitVersionTool {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getGitVersionOptions(): IGitVersionInput {
|
public getGitVersionInput(): GitVersionInput {
|
||||||
|
|
||||||
const targetPath = this.buildAgent.getInput(GitVersionRunOptions.targetPath);
|
const targetPath = this.buildAgent.getInput(GitVersionRunOptions.targetPath);
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ export class GitVersionTool implements IGitVersionTool {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public writeGitVersionToAgent(gitversion: IGitVersionOutput): void {
|
public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
|
||||||
|
|
||||||
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
||||||
this.buildAgent.setOutput("minor", gitversion.Minor.toString());
|
this.buildAgent.setOutput("minor", gitversion.Minor.toString());
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export const GitVersionRunOptions = {
|
|||||||
additionalArguments: "additionalArguments",
|
additionalArguments: "additionalArguments",
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IGitVersionInput {
|
export interface GitVersionInput {
|
||||||
targetPath: string;
|
targetPath: string;
|
||||||
useConfigFile: boolean;
|
useConfigFile: boolean;
|
||||||
configFilePath: string;
|
configFilePath: string;
|
||||||
@@ -17,7 +17,7 @@ export interface IGitVersionInput {
|
|||||||
srcDir: string;
|
srcDir: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IGitVersionOutput {
|
export interface GitVersionOutput {
|
||||||
Major: number;
|
Major: number;
|
||||||
Minor: number;
|
Minor: number;
|
||||||
Patch: number;
|
Patch: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user