From d81b2c5e15912f6b32cee1a76a78bb59e03e0c9f Mon Sep 17 00:00:00 2001 From: Maxime Brunet Date: Thu, 30 May 2024 20:04:57 +0000 Subject: [PATCH] fix(gomod): use plural for additional dependencies notice (#29361) --- .../manager/gomod/artifacts-extra.spec.ts | 24 ++++++++++++++++++- lib/modules/manager/gomod/artifacts-extra.ts | 6 ++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/modules/manager/gomod/artifacts-extra.spec.ts b/lib/modules/manager/gomod/artifacts-extra.spec.ts index ad6a9e1917d3c3..2f3654e80e7058 100644 --- a/lib/modules/manager/gomod/artifacts-extra.spec.ts +++ b/lib/modules/manager/gomod/artifacts-extra.spec.ts @@ -91,7 +91,7 @@ describe('modules/manager/gomod/artifacts-extra', () => { expect(res).toBeNull(); }); - it('returns a notice when there are extra dependencies', () => { + it('returns a notice when there is an extra dependency', () => { const excludeDeps = ['go', 'github.com/foo/foo']; const res = getExtraDepsNotice(goModBefore, goModAfter, excludeDeps); @@ -112,6 +112,28 @@ describe('modules/manager/gomod/artifacts-extra', () => { ); }); + it('returns a notice when there are extra dependencies', () => { + const excludeDeps = ['go']; + + const res = getExtraDepsNotice(goModBefore, goModAfter, excludeDeps); + + expect(res).toEqual( + [ + 'In order to perform the update(s) described in the table above, Renovate ran the `go get` command, which resulted in the following additional change(s):', + '', + '', + '- 2 additional dependencies were updated', + '', + '', + 'Details:', + '| **Package** | **Change** |', + '| :------------------- | :------------------- |', + '| `github.com/foo/foo` | `v1.0.0` -> `v1.1.1` |', + '| `github.com/bar/bar` | `v2.0.0` -> `v2.2.2` |', + ].join('\n'), + ); + }); + it('adds special notice for updated `go` version', () => { const excludeDeps = ['github.com/foo/foo']; diff --git a/lib/modules/manager/gomod/artifacts-extra.ts b/lib/modules/manager/gomod/artifacts-extra.ts index fbebc9efc20572..73e17cf51bf55c 100644 --- a/lib/modules/manager/gomod/artifacts-extra.ts +++ b/lib/modules/manager/gomod/artifacts-extra.ts @@ -94,8 +94,12 @@ export function getExtraDepsNotice( const goUpdated = extraDeps.some(({ depName }) => depName === 'go'); const otherDepsCount = extraDeps.length - (goUpdated ? 1 : 0); - if (otherDepsCount > 0) { + if (otherDepsCount === 1) { noticeLines.push(`- ${otherDepsCount} additional dependency was updated`); + } else if (otherDepsCount > 1) { + noticeLines.push( + `- ${otherDepsCount} additional dependencies were updated`, + ); } if (goUpdated) {