* Creates a git repo with the contents of a fixture. * @param {string} fixtureName Name of fixture. * @param {Object} options Repo options. * @return {Promise } A promise for the path to the repo.
(fixtureName, options)
| 43 | * @return {Promise<string>} A promise for the path to the repo. |
| 44 | */ |
| 45 | function setupRepo(fixtureName, options) { |
| 46 | const branch = options.branch || 'gh-pages'; |
| 47 | const userEmail = (options.user && options.user.email) || 'user@email.com'; |
| 48 | const userName = (options.user && options.user.name) || 'User Name'; |
| 49 | return mkdtemp() |
| 50 | .then((dir) => { |
| 51 | const fixturePath = path.join(fixtures, fixtureName, 'remote'); |
| 52 | return fs.copy(fixturePath, dir).then(() => new Git(dir)); |
| 53 | }) |
| 54 | .then((git) => git.init()) |
| 55 | .then((git) => git.exec('config', 'user.email', userEmail)) |
| 56 | .then((git) => git.exec('config', 'user.name', userName)) |
| 57 | .then((git) => git.exec('checkout', '--orphan', branch)) |
| 58 | .then((git) => git.add('.')) |
| 59 | .then((git) => git.commit('Initial commit')) |
| 60 | .then((git) => git.cwd); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Creates a git repo with the contents of a fixture and pushes to a remote. |
no test coverage detected
searching dependent graphs…