diff --git a/lib/workers/repository/finalize/index.ts b/lib/workers/repository/finalize/index.ts index 249c30345eaf81e7030457fec7993f35206f8f41..0a5064e445839907ed4fb32fd3c9d5fc61c22593 100644 --- a/lib/workers/repository/finalize/index.ts +++ b/lib/workers/repository/finalize/index.ts @@ -36,6 +36,6 @@ export async function finalizeRepo( logger.debug('Repo is activated'); config.repoIsActivated = true; } - runBranchSummary(); + 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 43bdd1fc3ec028c029c322fc657d0e0bff2036f9..3f2c323550e1be0fab3c1e7fcbc16c34fc7c2ee4 100644 --- a/lib/workers/repository/finalize/repository-statistics.spec.ts +++ b/lib/workers/repository/finalize/repository-statistics.spec.ts @@ -38,6 +38,7 @@ describe('workers/repository/finalize/repository-statistics', () => { it('Calls runRenovateRepoStats', () => { runRenovateRepoStats(config, result); + expect(logger.debug).toHaveBeenCalledWith( { stats: { @@ -55,6 +56,7 @@ describe('workers/repository/finalize/repository-statistics', () => { describe('runBranchSummary', () => { const getCacheSpy = jest.spyOn(cache, 'getCache'); const isCacheModifiedSpy = jest.spyOn(cache, 'isCacheModified'); + const config: RenovateConfig = {}; it('processes cache with baseBranches only', () => { const sha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad'; @@ -64,7 +66,9 @@ describe('workers/repository/finalize/repository-statistics', () => { }); getCacheSpy.mockReturnValueOnce(cache); isCacheModifiedSpy.mockReturnValueOnce(true); - runBranchSummary(); + + runBranchSummary(config); + expect(logger.debug).toHaveBeenCalledWith( { cacheModified: true, @@ -89,6 +93,8 @@ describe('workers/repository/finalize/repository-statistics', () => { const sha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad'; const baseBranchSha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad'; const baseBranch = 'base-branch'; + const defaultBranch = 'main'; + const config: RenovateConfig = { defaultBranch }; const baseCache = partial<BaseBranchCache>({ sha }); const branchCache = partial<BranchCache>({ sha, @@ -100,11 +106,11 @@ describe('workers/repository/finalize/repository-statistics', () => { }); const expectedMeta = { automerge: branchCache.automerge, - isModified: branchCache.isModified, - isPristine: branchCache.pristine, baseBranch, baseBranchSha, branchSha: sha, + isModified: branchCache.isModified, + isPristine: branchCache.pristine, }; const branches: BranchCache[] = [ { ...branchCache, branchName: 'b1' }, @@ -118,13 +124,13 @@ describe('workers/repository/finalize/repository-statistics', () => { scan: { main: baseCache, dev: baseCache }, branches, }); - getCacheSpy.mockReturnValueOnce(cache); isCacheModifiedSpy.mockReturnValueOnce(false); - runBranchSummary(); + + runBranchSummary(config); + expect(logger.debug).toHaveBeenCalledWith( { - cacheModified: false, baseBranches: [ { branchName: 'main', @@ -139,6 +145,8 @@ describe('workers/repository/finalize/repository-statistics', () => { { ...expectedMeta, branchName: 'b1' }, { ...expectedMeta, branchName: 'b2' }, ], + cacheModified: false, + defaultBranch, inactiveBranches: ['b3'], }, `Branch summary` diff --git a/lib/workers/repository/finalize/repository-statistics.ts b/lib/workers/repository/finalize/repository-statistics.ts index f69225f5dbc3c25c4ec809e35685a2190db5739d..1d3e487d6fd5bec0733aedc365bf275f2d03a63a 100644 --- a/lib/workers/repository/finalize/repository-statistics.ts +++ b/lib/workers/repository/finalize/repository-statistics.ts @@ -60,7 +60,7 @@ function branchCacheToMetadata({ }; } -export function runBranchSummary(): void { +export function runBranchSummary({ defaultBranch }: RenovateConfig): void { const { scan, branches } = getCache(); const baseMetadata: BaseBranchMetadata[] = []; @@ -83,6 +83,7 @@ export function runBranchSummary(): void { cacheModified: isCacheModified(), baseBranches: baseMetadata, branches: branchMetadata, + defaultBranch, inactiveBranches, }; diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 8357d49264a75a7ae1fd4544f79f6f7617c8d682..3a14f60295b1aeb13824cdfb38709d1c5098e08f 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -145,9 +145,10 @@ export interface BaseBranchMetadata { } export interface BranchSummary { - cacheModified?: boolean; baseBranches: BaseBranchMetadata[]; branches: BranchMetadata[]; + cacheModified?: boolean; + defaultBranch?: string; inactiveBranches: string[]; }