Fix fork PR builds

Remove hardcoded reference to the `origin` remote and instead implictly use the current commit or ref
This commit is contained in:
Benoit Dion 2020-06-15 16:35:53 -04:00 committed by Webber Takken
parent 229b0d02f8
commit 1245bfefc8
2 changed files with 10 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -39,6 +39,13 @@ export default class Versioning {
return process.env.GITHUB_REF;
}
/**
* The commit SHA that triggered the workflow run.
*/
static get sha() {
return process.env.GITHUB_SHA;
}
/**
* Regex to parse version description into separate fields
*/
@ -162,8 +169,7 @@ export default class Versioning {
* identifies the current commit.
*/
static async getVersionDescription() {
const commitIsh = (await this.getTag()) ? 'HEAD' : `origin/${this.branch}`;
return this.git(['describe', '--long', '--tags', '--always', '--debug', commitIsh]);
return this.git(['describe', '--long', '--tags', '--always', '--debug', this.sha]);
}
/**
@ -202,11 +208,7 @@ export default class Versioning {
* Note: HEAD should not be used, as it may be detached, resulting in an additional count.
*/
static async getTotalNumberOfCommits() {
const numberOfCommitsAsString = await this.git([
'rev-list',
'--count',
`origin/${this.branch}`,
]);
const numberOfCommitsAsString = await this.git(['rev-list', '--count', this.sha]);
return Number.parseInt(numberOfCommitsAsString, 10);
}