({ lfs })
| 83 | } |
| 84 | |
| 85 | async 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 | |
| 128 | async function getUser() { |
| 129 | const { token } = await getEnvs(); |
no test coverage detected