mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-24 22:48:06 +00:00
7ebba26236
* feat: add `commitHourlyLimit` Signed-off-by: Felipe Santos <felipe.santos@ericsson.com> * Update docs/usage/configuration-options.md Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com> * Remove date optionality * Fix lint comment * Fix coverage * Restore contents of commit.spec.ts * Use ! somewhere else too * Change optional parameter to nullish * Refactor `!` to use proper check * Fix set-branch-commit.spec.ts lint * Fix test coverage * Apply suggestions from code review Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com> * Split commit-limit-reached into two * Fix review comments * Use toUTC() where applicable * Simplify another test to utc() --------- Signed-off-by: Felipe Santos <felipe.santos@ericsson.com> Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { DateTime } from 'luxon';
|
|
import { logger } from '../../logger/index.ts';
|
|
import { getCache } from '../cache/repository/index.ts';
|
|
import type { BranchCache } from '../cache/repository/types.ts';
|
|
import { getBranchCommit } from './index.ts';
|
|
|
|
/**
|
|
* Called when a new commit is added to branch
|
|
*
|
|
* ie. when branch is created/updated
|
|
*/
|
|
export function setBranchNewCommit(
|
|
branchName: string,
|
|
baseBranch: string,
|
|
commitSha: string,
|
|
commitTimestamp: DateTime | null,
|
|
): void {
|
|
logger.debug('setBranchCommit()');
|
|
const cache = getCache();
|
|
cache.branches ??= [];
|
|
let branch = cache.branches.find((br) => br.branchName === branchName);
|
|
if (!branch) {
|
|
logger.debug(`setBranchCommit(): Branch cache not present`); // should never be called
|
|
branch = {
|
|
branchName,
|
|
baseBranch,
|
|
} as BranchCache;
|
|
cache.branches.push(branch);
|
|
}
|
|
|
|
const baseBranchSha = getBranchCommit(baseBranch);
|
|
|
|
branch.baseBranchSha = baseBranchSha;
|
|
branch.isBehindBase = false;
|
|
branch.isConflicted = false;
|
|
branch.isModified = false;
|
|
branch.pristine = true;
|
|
branch.sha = commitSha;
|
|
if (commitTimestamp) {
|
|
branch.commitTimestamp = commitTimestamp.toISO()!;
|
|
}
|
|
}
|