Skip to content

Commit

Permalink
fix(github-actions): Fix hash extraction (#18927)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored Nov 15, 2022
1 parent fc03eaf commit 30eb3dd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/modules/manager/github-actions/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,14 @@ describe('modules/manager/github-actions/extract', () => {
'actions/checkout@1e204e9a9253d643386038d443f96446fa156a97 #v2.1.0',
},
{
currentDigest: '1e204e',
currentDigestShort: '1e204e',
currentValue: 'v2.1.0',
replaceString: 'actions/checkout@1e204e # v2.1.0',
},
{
currentValue: '01aecc#v2.1.0',
replaceString: 'actions/checkout@01aecc#v2.1.0',
skipReason: 'invalid-version',
},
{
currentDigest: '689fcce700ae7ffc576f2b029b51b2ffb66d3abd',
Expand Down
6 changes: 5 additions & 1 deletion lib/modules/manager/github-actions/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const actionRe = regEx(
);

// SHA1 or SHA256, see https://github.blog/2020-10-19-git-2-29-released/
const shaRe = regEx(/^(?:[a-f0-9]{6,7}|[a-f0-9]{40}|[a-f0-9]{64})$/);
const shaRe = regEx(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/);
const shaShortRe = regEx(/^[a-f0-9]{6,7}$/);

function extractWithRegex(content: string): PackageDependency[] {
logger.trace('github-actions.extractWithRegex()');
Expand Down Expand Up @@ -60,6 +61,9 @@ function extractWithRegex(content: string): PackageDependency[] {
if (shaRe.test(currentValue)) {
dep.currentValue = tag;
dep.currentDigest = currentValue;
} else if (shaShortRe.test(currentValue)) {
dep.currentValue = tag;
dep.currentDigestShort = currentValue;
} else {
dep.currentValue = currentValue;
if (!dockerVersioning.api.isValid(currentValue)) {
Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/docker/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('modules/versioning/docker/index', () => {
${'0z1b2c3'} | ${true}
${'0A1b2c3d4e5f6a7b8c9d0a1b2c3d4e5f6a7b8c9d'} | ${true}
${'123098140293'} | ${true}
${'01aecc#v2.1.0'} | ${false}
`('isValid("$version") === $expected', ({ version, expected }) => {
const res = docker.isValid(version);
expect(!!res).toBe(expected);
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const urls = [
];
export const supportsRanges = false;

const versionPattern = regEx(/^(?<version>\d+(?:\.\d+)*)(?<prerelease>.*)$/);
const versionPattern = regEx(/^(?<version>\d+(?:\.\d+)*)(?<prerelease>\w*)$/);
const commitHashPattern = regEx(/^[a-f0-9]{7,40}$/);
const numericPattern = regEx(/^[0-9]+$/);

Expand Down

0 comments on commit 30eb3dd

Please sign in to comment.