make logging of git diff unconditional, remove parameter

This commit is contained in:
dogboydog
2020-07-08 19:48:46 -04:00
committed by Webber Takken
parent 6fb8550919
commit 91ec427695
7 changed files with 34 additions and 79 deletions

View File

@@ -13,10 +13,6 @@ export default class Versioning {
return Input.allowDirtyBuild === 'true';
}
static get logDiffIfDirty() {
return Input.logDiffIfDirty === 'true';
}
static get strategies() {
return { None: 'None', Semantic: 'Semantic', Tag: 'Tag', Custom: 'Custom' };
}
@@ -50,6 +46,20 @@ export default class Versioning {
return process.env.GITHUB_SHA;
}
/**
* Maximum number of lines to print when logging the git diff
*/
static get maxDiffLines() {
return 60;
}
/**
* Log up to maxDiffLines of the git diff.
*/
static async logDiff() {
this.git(['--no-pager', 'diff', '|', 'head', '-n', this.maxDiffLines.toString()]);
}
/**
* Regex to parse version description into separate fields
*/
@@ -99,6 +109,8 @@ export default class Versioning {
static async generateSemanticVersion() {
await this.fetch();
await this.logDiff();
if ((await this.isDirty()) && !this.isDirtyAllowed) {
throw new Error('Branch is dirty. Refusing to base semantic version on uncommitted changes');
}
@@ -182,12 +194,7 @@ export default class Versioning {
static async isDirty() {
const output = await this.git(['status', '--porcelain']);
const dirty = output !== '';
if (dirty && this.logDiffIfDirty) {
await this.git(['--no-pager', 'diff']);
}
return dirty;
return output !== '';
}
/**