diff --git a/lib/workers/repository/finalize/__fixtures__/branches.json b/lib/workers/repository/finalize/__fixtures__/branches.json deleted file mode 100644 index 847cc57f96d2ab..00000000000000 --- a/lib/workers/repository/finalize/__fixtures__/branches.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - { - "branchName": "renovate/lodash-monorepo", - "prTitle": "Update dependency lodash to v4.17.21", - "upgrades": [ - { - "datasource": "npm", - "depName": "lodash", - "fixedVersion": "4.17.20", - "currentVersion": "4.17.20", - "currentValue": "4.17.20", - "newValue": "4.17.21", - "newVersion": "4.17.21", - "packageFile": "package.json", - "updateType": "patch", - "packageName": "lodash" - } - ] - }, - { - "branchName": "renovate/date-io-monorepo", - "prTitle": "Update date-io monorepo to v2.17.0", - "upgrades": [ - { - "datasource": "npm", - "depName": "@date-io/date-fns", - "fixedVersion": "2.10.0", - "currentVersion": "2.10.0", - "currentValue": "2.10.0", - "newValue": "2.17.0", - "newVersion": "2.17.0", - "packageFile": "package.json", - "updateType": "minor", - "packageName": "@date-io/date-fns" - }, - { - "datasource": "npm", - "depName": "@date-io/moment", - "fixedVersion": "2.10.0", - "currentVersion": "2.10.0", - "currentValue": "2.10.0", - "newValue": "2.17.0", - "newVersion": "2.17.0", - "packageFile": "package.json", - "updateType": "minor", - "packageName": "@date-io/moment" - } - ] - }, - { - "branchName": "renovate/commander-11.x", - "prTitle": "Update dependency commander to v11", - "upgrades": [ - { - "datasource": "npm", - "depName": "commander", - "fixedVersion": "2.20.3", - "currentVersion": "2.20.3", - "currentValue": "2.20.3", - "newValue": "11.0.0", - "newVersion": "11.0.0", - "packageFile": "package.json", - "updateType": "major", - "packageName": "commander" - } - ] - } -] diff --git a/lib/workers/repository/finalize/index.ts b/lib/workers/repository/finalize/index.ts index 4c7b39364d6b7b..e0afb3893f1c1b 100644 --- a/lib/workers/repository/finalize/index.ts +++ b/lib/workers/repository/finalize/index.ts @@ -6,7 +6,10 @@ import { clearRenovateRefs } from '../../../util/git'; import { configMigration } from '../config-migration'; import { PackageFiles } from '../package-files'; import { pruneStaleBranches } from './prune'; -import { runRenovateRepoStats } from './repository-statistics'; +import { + runBranchSummary, + runRenovateRepoStats, +} from './repository-statistics'; // istanbul ignore next export async function finalizeRepo( @@ -31,6 +34,7 @@ export async function finalizeRepo( logger.debug('Repo is activated'); config.repoIsActivated = true; } + runBranchSummary(config); runRenovateRepoStats(config, prList); } diff --git a/lib/workers/repository/finalize/repository-statistics.spec.ts b/lib/workers/repository/finalize/repository-statistics.spec.ts index 6ed74cbae3cb2d..6d65e88af89a6f 100644 --- a/lib/workers/repository/finalize/repository-statistics.spec.ts +++ b/lib/workers/repository/finalize/repository-statistics.spec.ts @@ -18,7 +18,6 @@ jest.mock('../../../modules/platform/github/pr'); jest.mock('../../../util/http/github'); const prJson = Fixtures.getJson('./pr-list.json'); -const branchesJson = Fixtures.getJson('./branches.json'); const result = Object.keys(prJson).map((key) => { return prJson[key]; }); @@ -67,7 +66,7 @@ describe('workers/repository/finalize/repository-statistics', () => { getCacheSpy.mockReturnValueOnce(cache); isCacheModifiedSpy.mockReturnValueOnce(true); - runBranchSummary(config, []); + runBranchSummary(config); expect(logger.debug).toHaveBeenCalledWith( { @@ -128,7 +127,7 @@ describe('workers/repository/finalize/repository-statistics', () => { getCacheSpy.mockReturnValueOnce(cache); isCacheModifiedSpy.mockReturnValueOnce(false); - runBranchSummary(config, []); + runBranchSummary(config); expect(logger.debug).toHaveBeenCalledWith( { @@ -154,10 +153,11 @@ describe('workers/repository/finalize/repository-statistics', () => { ); }); - it('logs extended branch info', () => { + it('logs extended branch info if branchSummaryExtended', () => { const defaultBranch = 'main'; const config: RenovateConfig = { defaultBranch, + branchSummaryExtended: true, }; const branchCache = partial({ result: 'done', @@ -171,6 +171,7 @@ describe('workers/repository/finalize/repository-statistics', () => { }, ]), }); + const branches: BranchCache[] = [{ ...branchCache, branchName: 'b1' }]; const cache = partial({ scan: {}, @@ -179,22 +180,7 @@ describe('workers/repository/finalize/repository-statistics', () => { getCacheSpy.mockReturnValueOnce(cache); isCacheModifiedSpy.mockReturnValueOnce(false); - runBranchSummary(config, []); - - expect(logger.debug).toHaveBeenCalledTimes(2); - }); - - it('logs extended branch info on lookup only', () => { - const config: RenovateConfig = { - defaultBranch: 'main', - }; - const cache = partial({ - scan: {}, - }); - getCacheSpy.mockReturnValueOnce(cache); - isCacheModifiedSpy.mockReturnValueOnce(false); - - runBranchSummary(config, branchesJson); + runBranchSummary(config); expect(logger.debug).toHaveBeenCalledTimes(2); }); diff --git a/lib/workers/repository/finalize/repository-statistics.ts b/lib/workers/repository/finalize/repository-statistics.ts index 3eba820733b33b..e2b5224a5be35c 100644 --- a/lib/workers/repository/finalize/repository-statistics.ts +++ b/lib/workers/repository/finalize/repository-statistics.ts @@ -1,7 +1,6 @@ import type { RenovateConfig } from '../../../config/types'; import { logger } from '../../../logger'; import type { Pr } from '../../../modules/platform'; -import { coerceArray } from '../../../util/array'; import { getCache, isCacheModified } from '../../../util/cache/repository'; import type { BranchCache, @@ -9,10 +8,8 @@ import type { } from '../../../util/cache/repository/types'; import type { BaseBranchMetadata, - BranchConfig, BranchMetadata, BranchSummary, - BranchUpgradeConfig, } from '../../types'; export function runRenovateRepoStats( @@ -66,55 +63,6 @@ function branchCacheToMetadata({ }; } -function filterDependencyLookupData( - branches: BranchConfig[] -): Partial[] { - const branchesFiltered: Partial[] = []; - for (const branch of branches) { - const upgradesFiltered: Partial[] = []; - const { branchName, prTitle, upgrades } = branch; - - for (const upgrade of coerceArray(upgrades)) { - const { - datasource, - depName, - fixedVersion, - currentVersion, - currentValue, - newValue, - newVersion, - packageFile, - updateType, - packageName, - } = upgrade; - - const filteredUpgrade: Partial = { - datasource, - depName, - fixedVersion, - currentVersion, - currentValue, - newValue, - newVersion, - packageFile, - updateType, - packageName, - }; - upgradesFiltered.push(filteredUpgrade); - } - - const filteredBranch: Partial = { - branchName, - prTitle, - result: 'no-work', - upgrades: upgradesFiltered as BranchUpgradeConfig[], - }; - branchesFiltered.push(filteredBranch); - } - - return branchesFiltered; -} - function filterDependencyDashboardData( branches: BranchCache[] ): Partial[] { @@ -123,7 +71,7 @@ function filterDependencyDashboardData( const upgradesFiltered: Partial[] = []; const { branchName, prNo, prTitle, result, upgrades, prBlockedBy } = branch; - for (const upgrade of coerceArray(upgrades)) { + for (const upgrade of upgrades ?? []) { const { datasource, depName, @@ -168,10 +116,7 @@ function filterDependencyDashboardData( return branchesFiltered; } -export function runBranchSummary( - config: RenovateConfig, - lookupBranchConfig: BranchConfig[] -): void { +export function runBranchSummary(config: RenovateConfig): void { const defaultBranch = config.defaultBranch; const { scan, branches } = getCache(); @@ -201,13 +146,8 @@ export function runBranchSummary( logger.debug(res, 'Branch summary'); - let branchesInformation; if (branches?.length) { - branchesInformation = filterDependencyDashboardData(branches); - } else if (lookupBranchConfig?.length) { - branchesInformation = filterDependencyLookupData(lookupBranchConfig); - } - if (branchesInformation) { + const branchesInformation = filterDependencyDashboardData(branches); logger.debug({ branchesInformation }, 'branches info extended'); } } diff --git a/lib/workers/repository/index.ts b/lib/workers/repository/index.ts index e8023a7172a51e..2a9621a3674b87 100644 --- a/lib/workers/repository/index.ts +++ b/lib/workers/repository/index.ts @@ -23,7 +23,6 @@ import { ensureDependencyDashboard } from './dependency-dashboard'; import handleError from './error'; import { finalizeRepo } from './finalize'; import { pruneStaleBranches } from './finalize/prune'; -import { runBranchSummary } from './finalize/repository-statistics'; import { initRepo } from './init'; import { OnboardingState } from './onboarding/common'; import { ensureOnboardingPr } from './onboarding/pr'; @@ -95,7 +94,6 @@ export async function renovateRepository( // TODO #22198 repoResult = processResult(config, res!); } - runBranchSummary(config, branches); } catch (err) /* istanbul ignore next */ { setMeta({ repository: config.repository }); const errorRes = await handleError(config, err);