mirror of https://github.com/probot/probot.git
Merge branch 'master' into full-esm
This commit is contained in:
commit
9a5ee9fa78
File diff suppressed because it is too large
Load Diff
|
@ -74,8 +74,8 @@
|
|||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/supertest": "^6.0.0",
|
||||
"@vitest/coverage-v8": "^2.0.0",
|
||||
"@vitest/ui": "^2.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"@vitest/ui": "^3.0.0",
|
||||
"connect-sse": "^1.2.0",
|
||||
"execa": "^8.0.1",
|
||||
"fetch-mock": "^11.0.0",
|
||||
|
@ -88,9 +88,9 @@
|
|||
"sonic-boom": "^4.0.0",
|
||||
"supertest": "^7.0.0",
|
||||
"tsd": "^0.31.0",
|
||||
"typedoc": "^0.26.0",
|
||||
"typedoc": "^0.27.0",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^2.0.0"
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
|
|
|
@ -42,6 +42,8 @@ type RepoResultType<E extends WebhookEvents> = {
|
|||
repo: RepoNameType<E>;
|
||||
};
|
||||
|
||||
const kOctokitRequestHookAdded = Symbol("octokit request hook added");
|
||||
|
||||
/**
|
||||
* The context of the event that was triggered, including the payload and
|
||||
* helpers for extracting information can be passed to GitHub API calls.
|
||||
|
@ -81,10 +83,13 @@ export class Context<Event extends WebhookEvents = WebhookEvents> {
|
|||
// This is not documented and not considered public API, the header may change.
|
||||
// Once we document this as best practice on https://docs.github.com/en/rest/guides/best-practices-for-integrators
|
||||
// we will make it official
|
||||
/* istanbul ignore next */
|
||||
octokit.hook.before("request", (options) => {
|
||||
options.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
if ((octokit as any)[kOctokitRequestHookAdded] !== true) {
|
||||
/* istanbul ignore next */
|
||||
octokit.hook.before("request", (options) => {
|
||||
options.headers["x-github-delivery"] = event.id;
|
||||
});
|
||||
(octokit as any)[kOctokitRequestHookAdded] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
import type { Logger } from "pino";
|
||||
|
||||
const kIsBound = Symbol("is-bound");
|
||||
|
||||
export function rebindLog(log: Logger): Logger {
|
||||
// @ts-ignore
|
||||
if (log[kIsBound]) return log;
|
||||
for (const key in log) {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
if (typeof log[key] !== "function") continue;
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
log[key] = log[key].bind(log);
|
||||
}
|
||||
// @ts-ignore
|
||||
log[kIsBound] = true;
|
||||
return log;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { State } from "../types.js";
|
|||
import type { ProbotOctokit } from "./probot-octokit.js";
|
||||
import type { OctokitOptions } from "../types.js";
|
||||
import type { LogFn, Level, Logger } from "pino";
|
||||
import { rebindLog } from "../helpers/rebind-log.js";
|
||||
|
||||
type FactoryOptions = {
|
||||
octokit: ProbotOctokit;
|
||||
|
@ -28,14 +29,7 @@ export async function getAuthenticatedOctokit(
|
|||
log: Record<Level, LogFn>;
|
||||
} = {
|
||||
...octokitOptions,
|
||||
log: {
|
||||
fatal: pinoLog.fatal.bind(pinoLog),
|
||||
error: pinoLog.error.bind(pinoLog),
|
||||
warn: pinoLog.warn.bind(pinoLog),
|
||||
info: pinoLog.info.bind(pinoLog),
|
||||
debug: pinoLog.debug.bind(pinoLog),
|
||||
trace: pinoLog.trace.bind(pinoLog),
|
||||
},
|
||||
log: rebindLog(pinoLog),
|
||||
throttle: octokitOptions.throttle?.enabled
|
||||
? {
|
||||
...octokitOptions.throttle,
|
||||
|
|
|
@ -85,12 +85,7 @@ export class Probot {
|
|||
const octokitLogger = rebindLog(this.log.child({ name: "octokit" }));
|
||||
const octokit = new Octokit({
|
||||
request: options.request,
|
||||
log: {
|
||||
debug: octokitLogger.debug.bind(octokitLogger),
|
||||
info: octokitLogger.info.bind(octokitLogger),
|
||||
warn: octokitLogger.warn.bind(octokitLogger),
|
||||
error: octokitLogger.error.bind(octokitLogger),
|
||||
},
|
||||
log: octokitLogger,
|
||||
});
|
||||
|
||||
this.state = {
|
||||
|
|
Loading…
Reference in New Issue