mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +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');
|
logger.debug('Repo is activated');
|
||||||
config.repoIsActivated = true;
|
config.repoIsActivated = true;
|
||||||
}
|
}
|
||||||
runBranchSummary();
|
runBranchSummary(config);
|
||||||
runRenovateRepoStats(config, prList);
|
runRenovateRepoStats(config, prList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
|
|
||||||
it('Calls runRenovateRepoStats', () => {
|
it('Calls runRenovateRepoStats', () => {
|
||||||
runRenovateRepoStats(config, result);
|
runRenovateRepoStats(config, result);
|
||||||
|
|
||||||
expect(logger.debug).toHaveBeenCalledWith(
|
expect(logger.debug).toHaveBeenCalledWith(
|
||||||
{
|
{
|
||||||
stats: {
|
stats: {
|
||||||
|
@ -55,6 +56,7 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
describe('runBranchSummary', () => {
|
describe('runBranchSummary', () => {
|
||||||
const getCacheSpy = jest.spyOn(cache, 'getCache');
|
const getCacheSpy = jest.spyOn(cache, 'getCache');
|
||||||
const isCacheModifiedSpy = jest.spyOn(cache, 'isCacheModified');
|
const isCacheModifiedSpy = jest.spyOn(cache, 'isCacheModified');
|
||||||
|
const config: RenovateConfig = {};
|
||||||
|
|
||||||
it('processes cache with baseBranches only', () => {
|
it('processes cache with baseBranches only', () => {
|
||||||
const sha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad';
|
const sha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad';
|
||||||
|
@ -64,7 +66,9 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
});
|
});
|
||||||
getCacheSpy.mockReturnValueOnce(cache);
|
getCacheSpy.mockReturnValueOnce(cache);
|
||||||
isCacheModifiedSpy.mockReturnValueOnce(true);
|
isCacheModifiedSpy.mockReturnValueOnce(true);
|
||||||
runBranchSummary();
|
|
||||||
|
runBranchSummary(config);
|
||||||
|
|
||||||
expect(logger.debug).toHaveBeenCalledWith(
|
expect(logger.debug).toHaveBeenCalledWith(
|
||||||
{
|
{
|
||||||
cacheModified: true,
|
cacheModified: true,
|
||||||
|
@ -89,6 +93,8 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
const sha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad';
|
const sha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad';
|
||||||
const baseBranchSha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad';
|
const baseBranchSha = '793221454914cdc422e1a8f0ca27b96fe39ff9ad';
|
||||||
const baseBranch = 'base-branch';
|
const baseBranch = 'base-branch';
|
||||||
|
const defaultBranch = 'main';
|
||||||
|
const config: RenovateConfig = { defaultBranch };
|
||||||
const baseCache = partial<BaseBranchCache>({ sha });
|
const baseCache = partial<BaseBranchCache>({ sha });
|
||||||
const branchCache = partial<BranchCache>({
|
const branchCache = partial<BranchCache>({
|
||||||
sha,
|
sha,
|
||||||
|
@ -100,11 +106,11 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
});
|
});
|
||||||
const expectedMeta = {
|
const expectedMeta = {
|
||||||
automerge: branchCache.automerge,
|
automerge: branchCache.automerge,
|
||||||
isModified: branchCache.isModified,
|
|
||||||
isPristine: branchCache.pristine,
|
|
||||||
baseBranch,
|
baseBranch,
|
||||||
baseBranchSha,
|
baseBranchSha,
|
||||||
branchSha: sha,
|
branchSha: sha,
|
||||||
|
isModified: branchCache.isModified,
|
||||||
|
isPristine: branchCache.pristine,
|
||||||
};
|
};
|
||||||
const branches: BranchCache[] = [
|
const branches: BranchCache[] = [
|
||||||
{ ...branchCache, branchName: 'b1' },
|
{ ...branchCache, branchName: 'b1' },
|
||||||
|
@ -118,13 +124,13 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
scan: { main: baseCache, dev: baseCache },
|
scan: { main: baseCache, dev: baseCache },
|
||||||
branches,
|
branches,
|
||||||
});
|
});
|
||||||
|
|
||||||
getCacheSpy.mockReturnValueOnce(cache);
|
getCacheSpy.mockReturnValueOnce(cache);
|
||||||
isCacheModifiedSpy.mockReturnValueOnce(false);
|
isCacheModifiedSpy.mockReturnValueOnce(false);
|
||||||
runBranchSummary();
|
|
||||||
|
runBranchSummary(config);
|
||||||
|
|
||||||
expect(logger.debug).toHaveBeenCalledWith(
|
expect(logger.debug).toHaveBeenCalledWith(
|
||||||
{
|
{
|
||||||
cacheModified: false,
|
|
||||||
baseBranches: [
|
baseBranches: [
|
||||||
{
|
{
|
||||||
branchName: 'main',
|
branchName: 'main',
|
||||||
|
@ -139,6 +145,8 @@ describe('workers/repository/finalize/repository-statistics', () => {
|
||||||
{ ...expectedMeta, branchName: 'b1' },
|
{ ...expectedMeta, branchName: 'b1' },
|
||||||
{ ...expectedMeta, branchName: 'b2' },
|
{ ...expectedMeta, branchName: 'b2' },
|
||||||
],
|
],
|
||||||
|
cacheModified: false,
|
||||||
|
defaultBranch,
|
||||||
inactiveBranches: ['b3'],
|
inactiveBranches: ['b3'],
|
||||||
},
|
},
|
||||||
`Branch summary`
|
`Branch summary`
|
||||||
|
|
|
@ -60,7 +60,7 @@ function branchCacheToMetadata({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runBranchSummary(): void {
|
export function runBranchSummary({ defaultBranch }: RenovateConfig): void {
|
||||||
const { scan, branches } = getCache();
|
const { scan, branches } = getCache();
|
||||||
|
|
||||||
const baseMetadata: BaseBranchMetadata[] = [];
|
const baseMetadata: BaseBranchMetadata[] = [];
|
||||||
|
@ -83,6 +83,7 @@ export function runBranchSummary(): void {
|
||||||
cacheModified: isCacheModified(),
|
cacheModified: isCacheModified(),
|
||||||
baseBranches: baseMetadata,
|
baseBranches: baseMetadata,
|
||||||
branches: branchMetadata,
|
branches: branchMetadata,
|
||||||
|
defaultBranch,
|
||||||
inactiveBranches,
|
inactiveBranches,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -145,9 +145,10 @@ export interface BaseBranchMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BranchSummary {
|
export interface BranchSummary {
|
||||||
cacheModified?: boolean;
|
|
||||||
baseBranches: BaseBranchMetadata[];
|
baseBranches: BaseBranchMetadata[];
|
||||||
branches: BranchMetadata[];
|
branches: BranchMetadata[];
|
||||||
|
cacheModified?: boolean;
|
||||||
|
defaultBranch?: string;
|
||||||
inactiveBranches: string[];
|
inactiveBranches: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue