chore: fix eslint errors introduced in phase 4 backend
This commit is contained in:
@@ -17,7 +17,7 @@ export const verifyGithubSignature = async (
|
|||||||
rawBody: string,
|
rawBody: string,
|
||||||
signatureHeader: string | null,
|
signatureHeader: string | null,
|
||||||
): Promise<boolean> => {
|
): Promise<boolean> => {
|
||||||
if (!signatureHeader || !signatureHeader.startsWith('sha256=')) return false;
|
if (!signatureHeader?.startsWith('sha256=')) return false;
|
||||||
// Web Crypto's importKey throws on a zero-length HMAC key; guard so the
|
// Web Crypto's importKey throws on a zero-length HMAC key; guard so the
|
||||||
// verifier never throws on attacker-controlled input (returns false instead).
|
// verifier never throws on attacker-controlled input (returns false instead).
|
||||||
if (!secret) return false;
|
if (!secret) return false;
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ export const maintenanceDedupKey = (input: {
|
|||||||
}): string | null => {
|
}): string | null => {
|
||||||
const head = input.headSha?.trim();
|
const head = input.headSha?.trim();
|
||||||
if (!head) return null;
|
if (!head) return null;
|
||||||
|
// Intentional `||`: an empty/whitespace merge base must collapse to the
|
||||||
|
// 'nobase' sentinel, which `??` would not do (it keeps the empty string).
|
||||||
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
const base = input.mergeBaseSha?.trim() || 'nobase';
|
const base = input.mergeBaseSha?.trim() || 'nobase';
|
||||||
return `${base}:${head}`;
|
return `${base}:${head}`;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
|
|
||||||
describe('resolveBranchHead', () => {
|
describe('resolveBranchHead', () => {
|
||||||
it('returns the branch tip sha from the branch ref', async () => {
|
it('returns the branch tip sha from the branch ref', async () => {
|
||||||
const getBranch = vi.fn(async () => ({
|
const getBranch = vi.fn(() =>
|
||||||
data: { commit: { sha: 'deadbeef' } },
|
Promise.resolve({ data: { commit: { sha: 'deadbeef' } } }),
|
||||||
}));
|
);
|
||||||
const octokit = {
|
const octokit = {
|
||||||
rest: { repos: { getBranch } },
|
rest: { repos: { getBranch } },
|
||||||
} as unknown as Octokit;
|
} as unknown as Octokit;
|
||||||
@@ -45,10 +45,9 @@ describe('compareAcrossForkNetwork', () => {
|
|||||||
makeCommit(i === 49 ? 'LAST_COMMIT_NOT_TIP' : `c${100 + i}`),
|
makeCommit(i === 49 ? 'LAST_COMMIT_NOT_TIP' : `c${100 + i}`),
|
||||||
);
|
);
|
||||||
|
|
||||||
const compareCommitsWithBasehead = vi.fn(
|
const compareCommitsWithBasehead = vi.fn(({ page }: { page?: number }) => {
|
||||||
async ({ page }: { page?: number }) => {
|
|
||||||
const commits = page === 2 ? page2 : page1;
|
const commits = page === 2 ? page2 : page1;
|
||||||
return {
|
return Promise.resolve({
|
||||||
data: {
|
data: {
|
||||||
total_commits: 150,
|
total_commits: 150,
|
||||||
ahead_by: 150,
|
ahead_by: 150,
|
||||||
@@ -57,12 +56,11 @@ describe('compareAcrossForkNetwork', () => {
|
|||||||
html_url: 'https://github.com/o/r/compare/base...head',
|
html_url: 'https://github.com/o/r/compare/base...head',
|
||||||
commits,
|
commits,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
},
|
});
|
||||||
|
const getBranch = vi.fn(() =>
|
||||||
|
Promise.resolve({ data: { commit: { sha: 'TIP' } } }),
|
||||||
);
|
);
|
||||||
const getBranch = vi.fn(async () => ({
|
|
||||||
data: { commit: { sha: 'TIP' } },
|
|
||||||
}));
|
|
||||||
const octokit = {
|
const octokit = {
|
||||||
rest: { repos: { compareCommitsWithBasehead, getBranch } },
|
rest: { repos: { compareCommitsWithBasehead, getBranch } },
|
||||||
} as unknown as Octokit;
|
} as unknown as Octokit;
|
||||||
|
|||||||
Reference in New Issue
Block a user