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

Function prepareTestBitBucketRepo

cypress/plugins/bitbucket.js:85–126  ·  view source on GitHub ↗
({ lfs })

Source from the content-addressed store, hash-verified

83}
84
85async function prepareTestBitBucketRepo({ lfs }) {
86 const { owner, repo, token } = await getEnvs();
87
88 // postfix a random string to avoid collisions
89 const postfix = Math.random()
90 .toString(32)
91 .slice(2);
92 const testRepoName = `${repo}-${Date.now()}-${postfix}`;
93
94 console.log('Creating repository', testRepoName);
95 await post(token, `repositories/${owner}/${testRepoName}`, JSON.stringify({ scm: 'git' }));
96
97 const tempDir = path.join('.temp', testRepoName);
98 await fs.remove(tempDir);
99 let git = getGitClient();
100
101 const repoUrl = `git@bitbucket.org:${owner}/${repo}.git`;
102
103 console.log('Cloning repository', repoUrl);
104 await git.clone(repoUrl, tempDir);
105 git = getGitClient(tempDir);
106
107 console.log('Pushing to new repository', testRepoName);
108
109 await git.removeRemote('origin');
110 await git.addRemote(
111 'origin',
112 `https://x-token-auth:${token}@bitbucket.org/${owner}/${testRepoName}`,
113 );
114 await git.push(['-u', 'origin', 'master']);
115
116 if (lfs) {
117 console.log(`Enabling LFS for repo ${owner}/${repo}`);
118 await git.addConfig('commit.gpgsign', 'false');
119 await git.raw(['lfs', 'track', '*.png', '*.jpg']);
120 await git.add('.gitattributes');
121 await git.commit('chore: track images files under LFS');
122 await git.push('origin', 'master');
123 }
124
125 return { owner, repo: testRepoName, tempDir };
126}
127
128async function getUser() {
129 const { token } = await getEnvs();

Callers 1

setupBitBucketFunction · 0.85

Calls 5

postFunction · 0.85
getGitClientFunction · 0.85
getEnvsFunction · 0.70
toStringMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected