Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action/index.js

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/model/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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]);
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down