MCPcopy
hub / github.com/tschaub/gh-pages / setupRepo

Function setupRepo

test/helper.js:45–61  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

43 * @return {Promise<string>} A promise for the path to the repo.
44 */
45function 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.

Callers 1

setupRemoteFunction · 0.85

Calls 1

mkdtempFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…