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

Function prepareTestGitLabRepo

cypress/plugins/gitlab.js:49–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49async function prepareTestGitLabRepo() {
50 const { owner, repo, token } = getEnvs();
51
52 // postfix a random string to avoid collisions
53 const postfix = Math.random()
54 .toString(32)
55 .slice(2);
56 const testRepoName = `${repo}-${Date.now()}-${postfix}`;
57
58 const client = getGitLabClient(token);
59
60 console.log('Creating repository', testRepoName);
61 await client.Projects.create({
62 name: testRepoName,
63 lfs_enabled: false,
64 });
65
66 const tempDir = path.join('.temp', testRepoName);
67 await fs.remove(tempDir);
68 let git = getGitClient();
69
70 const repoUrl = `git@gitlab.com:${owner}/${repo}.git`;
71
72 console.log('Cloning repository', repoUrl);
73 await git.clone(repoUrl, tempDir);
74 git = getGitClient(tempDir);
75
76 console.log('Pushing to new repository', testRepoName);
77
78 await git.removeRemote('origin');
79 await git.addRemote('origin', `https://oauth2:${token}@gitlab.com/${owner}/${testRepoName}`);
80 await git.push(['-u', 'origin', 'master']);
81
82 await client.ProtectedBranches.unprotect(`${owner}/${testRepoName}`, 'master');
83
84 return { owner, repo: testRepoName, tempDir };
85}
86
87async function getAuthenticatedUser(token) {
88 const client = getGitLabClient(token);

Callers 1

setupGitLabFunction · 0.85

Calls 5

getGitLabClientFunction · 0.85
getGitClientFunction · 0.85
createMethod · 0.80
getEnvsFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected