MCPcopy
hub / github.com/iterative/cml / octokit

Function octokit

src/drivers/github.js:53–84  ·  view source on GitHub ↗
(token, repo, log)

Source from the content-addressed store, hash-verified

51};
52
53const octokit = (token, repo, log) => {
54 if (!token) throw new Error('token not found');
55
56 const throttleHandler = (reason, offset) => async (retryAfter, options) => {
57 if (options.request.retryCount <= 5) {
58 logger.info(
59 `Retrying because of ${reason} in ${retryAfter + offset} seconds`
60 );
61 await new Promise((resolve) => setTimeout(resolve, offset * 1000));
62 return true;
63 }
64 };
65 const octokitOptions = {
66 request: { agent: new ProxyAgent() },
67 auth: token,
68 log,
69 throttle: {
70 onAbuseLimit: throttleHandler('abuse limit', 120), // deprecated, see onSecondaryRateLimit
71 onRateLimit: throttleHandler('rate limit', 30),
72 onSecondaryRateLimit: throttleHandler('secondary rate limit', 30)
73 }
74 };
75 const { host, hostname } = new url.URL(repo);
76 if (hostname !== 'github.com') {
77 // GitHub Enterprise, use the: repo URL host + '/api/v3' - as baseURL
78 // as per: https://developer.github.com/enterprise/v3/enterprise-admin/#endpoint-urls
79 octokitOptions.baseUrl = `https://${host}/api/v3`;
80 }
81
82 const MyOctokit = Octokit.plugin(throttling);
83 return new MyOctokit(octokitOptions);
84};
85
86class Github {
87 constructor(opts = {}) {

Callers 15

userMethod · 0.85
commitCommentCreateMethod · 0.85
commitCommentUpdateMethod · 0.85
commitCommentsMethod · 0.85
commitPrsMethod · 0.85
checkCreateMethod · 0.85
runnerTokenMethod · 0.85
unregisterRunnerMethod · 0.85
runnersMethod · 0.85
runnerByIdMethod · 0.85
runnerJobMethod · 0.85
prCreateMethod · 0.85

Calls 1

throttleHandlerFunction · 0.85

Tested by

no test coverage detected