mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 06:26:26 +00:00
feat(logs): log default branch in branch summary (#21855)
This commit is contained in:
parent
540fa972f2
commit
81b69bb4ef
4 changed files with 19 additions and 9 deletions
|
@ -36,6 +36,6 @@ export async function finalizeRepo(
|
|||
logger.debug('Repo is activated');
|
||||
config.repoIsActivated = true;
|
||||
}
|
||||
runBranchSummary();
|
||||
runBranchSummary(config);
|
||||
runRenovateRepoStats(config, prList);
|
||||
}
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -145,9 +145,10 @@ export interface BaseBranchMetadata {
|
|||
}
|
||||
|
||||
export interface BranchSummary {
|
||||
cacheModified?: boolean;
|
||||
baseBranches: BaseBranchMetadata[];
|
||||
branches: BranchMetadata[];
|
||||
cacheModified?: boolean;
|
||||
defaultBranch?: string;
|
||||
inactiveBranches: string[];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue