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

Function prepareTestGitHubRepo

cypress/plugins/github.js:58–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58async function prepareTestGitHubRepo() {
59 const { owner, repo, token } = getEnvs();
60
61 // postfix a random string to avoid collisions
62 const postfix = Math.random()
63 .toString(32)
64 .slice(2);
65 const testRepoName = `${repo}-${Date.now()}-${postfix}`;
66
67 const client = getGitHubClient(token);
68
69 console.log('Creating repository', testRepoName);
70 await client.repos.createForAuthenticatedUser({
71 name: testRepoName,
72 });
73
74 const tempDir = path.join('.temp', testRepoName);
75 await fs.remove(tempDir);
76 let git = getGitClient();
77
78 const repoUrl = `git@github.com:${owner}/${repo}.git`;
79
80 console.log('Cloning repository', repoUrl);
81 await git.clone(repoUrl, tempDir);
82 git = getGitClient(tempDir);
83
84 console.log('Pushing to new repository', testRepoName);
85
86 await git.removeRemote('origin');
87 await git.addRemote(
88 'origin',
89 `https://${token}:x-oauth-basic@github.com/${owner}/${testRepoName}`,
90 );
91 await git.push(['-u', 'origin', 'master']);
92
93 return { owner, repo: testRepoName, tempDir };
94}
95
96async function getAuthenticatedUser(token) {
97 const client = getGitHubClient(token);

Callers 1

setupGitHubFunction · 0.85

Calls 4

getGitHubClientFunction · 0.85
getGitClientFunction · 0.85
getEnvsFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected