MCPcopy Create free account
hub / github.com/decaporg/decap-cms / seedGitHubRepo

Function seedGitHubRepo

cypress/plugins/github.js:429–485  ·  view source on GitHub ↗
(taskData)

Source from the content-addressed store, hash-verified

427}
428
429async function seedGitHubRepo(taskData) {
430 if (process.env.RECORD_FIXTURES) {
431 const { owner, token } = getEnvs();
432
433 const client = getGitHubClient(token);
434 const repo = taskData.repo;
435
436 try {
437 console.log('Getting master branch');
438 const { data: master } = await client.repos.getBranch({
439 owner,
440 repo,
441 branch: 'master',
442 });
443
444 const prCount = 120;
445 const prs = new Array(prCount).fill(0).map((v, i) => i);
446 const batchSize = 5;
447 await batchRequests(prs, batchSize, async i => {
448 const branch = `seed_branch_${i}`;
449 console.log(`Creating branch ${branch}`);
450 await client.git.createRef({
451 owner,
452 repo,
453 ref: `refs/heads/${branch}`,
454 sha: master.commit.sha,
455 });
456
457 const path = `seed/file_${i}`;
458 console.log(`Creating file ${path}`);
459 await client.repos.createOrUpdateFile({
460 owner,
461 repo,
462 branch,
463 content: Buffer.from(`Seed File ${i}`).toString('base64'),
464 message: `Create seed file ${i}`,
465 path,
466 });
467
468 const title = `Non CMS Pull Request ${i}`;
469 console.log(`Creating PR ${title}`);
470 await client.pulls.create({
471 owner,
472 repo,
473 base: 'master',
474 head: branch,
475 title,
476 });
477 });
478 } catch (e) {
479 console.log(e);
480 throw e;
481 }
482 }
483
484 return null;
485}
486

Callers 1

seedRepoFunction · 0.85

Calls 8

getGitHubClientFunction · 0.85
batchRequestsFunction · 0.85
mapMethod · 0.80
createRefMethod · 0.80
createMethod · 0.80
getEnvsFunction · 0.70
getBranchMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected