MCPcopy Index your code
hub / github.com/wei/pull / getDefaultPullConfig

Function getDefaultPullConfig

src/utils/get-pull-config.ts:38–76  ·  view source on GitHub ↗
(
  repository: RestEndpointMethodTypes["repos"]["get"]["response"]["data"],
  log: Logger,
)

Source from the content-addressed store, hash-verified

36}
37
38function getDefaultPullConfig(
39 repository: RestEndpointMethodTypes["repos"]["get"]["response"]["data"],
40 log: Logger,
41): PullConfig | null {
42 log.debug(`⚙️ Fetching default config`);
43
44 if (repository.fork && repository.parent) {
45 const upstreamOwner = repository.parent.owner &&
46 repository.parent.owner.login;
47 const defaultBranch = repository.parent.default_branch;
48
49 if (upstreamOwner && defaultBranch) {
50 log.debug(
51 `Using default config ${defaultBranch}...${upstreamOwner}:${defaultBranch}`,
52 );
53
54 const defaultConfig = {
55 version: "1",
56 rules: [
57 {
58 base: `${defaultBranch}`,
59 upstream: `${upstreamOwner}:${defaultBranch}`,
60 mergeMethod: appConfig.defaultMergeMethod,
61 mergeUnstable: true,
62 },
63 ],
64 };
65
66 const result = pullConfigSchema.safeParse(defaultConfig);
67 if (!result.success) {
68 throw new Error("Invalid default config");
69 }
70
71 return result.data;
72 }
73 }
74
75 return null;
76}
77
78export async function getPullConfig(
79 octokit: ProbotOctokit,

Callers 1

getPullConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected