diff --git a/services/text-formatters.js b/services/text-formatters.js index a1eb1710053e9..185170e023148 100644 --- a/services/text-formatters.js +++ b/services/text-formatters.js @@ -127,11 +127,12 @@ function omitv(version) { return version } -const ignoredVersionPatterns = /^[^0-9]|[0-9]{4}-[0-9]{2}-[0-9]{2}/ +const ignoredVersionPatterns = + /^[^0-9]|[0-9]{4}-[0-9]{2}-[0-9]{2}|^[a-f0-9]{7,40}$/ /** - * Add a starting v to the version unless it doesn't starts with a digit or is a date (yyyy-mm-dd) - * For example, addv("1.2.3") returns "v1.2.3", but addv("hello") or addv("2021-10-31"), returns "hello" and "2021-10-31" respectively. + * Add a starting v to the version unless it doesn't starts with a digit, is a date (yyyy-mm-dd), or is a commit hash. + * For example, addv("1.2.3") returns "v1.2.3", but addv("hello"), addv("2021-10-31"), addv("abcdef1"), returns "hello", "2021-10-31", and "abcdef1" respectively. * * @param {string} version - Version string * @returns {string} Version string with the starting v diff --git a/services/text-formatters.spec.js b/services/text-formatters.spec.js index 5985a4a465e6f..8dedef13a32be 100644 --- a/services/text-formatters.spec.js +++ b/services/text-formatters.spec.js @@ -96,6 +96,10 @@ describe('Text formatters', function () { given('v0.6').expect('v0.6') given('hello').expect('hello') given('2017-05-05-Release-2.3.17').expect('2017-05-05-Release-2.3.17') + given('5aa272da7924fa76581fd5ea83b24cfbb3528b8a').expect( + '5aa272da7924fa76581fd5ea83b24cfbb3528b8a', + ) + given('5aa272da79').expect('5aa272da79') }) test(maybePluralize, () => {