Fix for #417. When pulling in other git histories, the github.sha is invalid. Thus by using HEAD we will version based on the checked out sha. Tested with PR, commits, and tags and was unable to reproduce any extra counting when comparing outputs between HEAD and explicit sha values regardless of detached head state.
parent
7e4d92cad3
commit
89cf8ec79c
|
|
@ -7395,12 +7395,6 @@ class Versioning {
|
|||
static get ref() {
|
||||
return process.env.GITHUB_REF;
|
||||
}
|
||||
/**
|
||||
* The commit SHA that triggered the workflow run.
|
||||
*/
|
||||
static get sha() {
|
||||
return process.env.GITHUB_SHA;
|
||||
}
|
||||
/**
|
||||
* Maximum number of lines to print when logging the git diff
|
||||
*/
|
||||
|
|
@ -7545,7 +7539,7 @@ class Versioning {
|
|||
* identifies the current commit.
|
||||
*/
|
||||
static async getVersionDescription() {
|
||||
return this.git(['describe', '--long', '--tags', '--always', this.sha]);
|
||||
return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
|
||||
}
|
||||
/**
|
||||
* Returns whether there are uncommitted changes that are not ignored.
|
||||
|
|
@ -7582,10 +7576,9 @@ class Versioning {
|
|||
/**
|
||||
* Get the total number of commits on head.
|
||||
*
|
||||
* 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', this.sha]);
|
||||
const numberOfCommitsAsString = await this.git(['rev-list', '--count', 'HEAD']);
|
||||
return Number.parseInt(numberOfCommitsAsString, 10);
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -34,13 +34,6 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum number of lines to print when logging the git diff
|
||||
*/
|
||||
|
|
@ -214,7 +207,7 @@ export default class Versioning {
|
|||
* identifies the current commit.
|
||||
*/
|
||||
static async getVersionDescription() {
|
||||
return this.git(['describe', '--long', '--tags', '--always', this.sha!]);
|
||||
return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -259,10 +252,9 @@ export default class Versioning {
|
|||
/**
|
||||
* Get the total number of commits on head.
|
||||
*
|
||||
* 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', this.sha!]);
|
||||
const numberOfCommitsAsString = await this.git(['rev-list', '--count', 'HEAD']);
|
||||
|
||||
return Number.parseInt(numberOfCommitsAsString, 10);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue