Files
renovate/lib/util/git/set-branch-commit.ts
Felipe Santos 7ebba26236 feat: add commitHourlyLimit (#36226)
* 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>
2026-02-19 18:00:32 +00:00

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()!;
}
}