* @param {string} dir The dir. * @param {string} url The url. * @param {string} branch The branch. * @return {Promise} A promise.
(dir, url, branch)
| 88 | * @return {Promise} A promise. |
| 89 | */ |
| 90 | function assertContentsMatch(dir, url, branch) { |
| 91 | return mkdtemp() |
| 92 | .then((root) => { |
| 93 | const clone = path.join(root, 'repo'); |
| 94 | const options = {git: 'git', remote: 'origin', depth: 1}; |
| 95 | return Git.clone(url, clone, branch, options); |
| 96 | }) |
| 97 | .then((git) => { |
| 98 | const comparison = compare(dir, git.cwd, {excludeFilter: '.git'}); |
| 99 | if (comparison.same) { |
| 100 | return true; |
| 101 | } else { |
| 102 | const message = comparison.diffSet |
| 103 | .map((entry) => { |
| 104 | const state = { |
| 105 | equal: '==', |
| 106 | left: '->', |
| 107 | right: '<-', |
| 108 | distinct: '<>', |
| 109 | }[entry.state]; |
| 110 | const name1 = entry.name1 ? entry.name1 : '<none>'; |
| 111 | const name2 = entry.name2 ? entry.name2 : '<none>'; |
| 112 | |
| 113 | return [name1, state, name2].join(' '); |
| 114 | }) |
| 115 | .join('\n'); |
| 116 | throw new Error('Directories do not match:\n' + message); |
| 117 | } |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | exports.assertContentsMatch = assertContentsMatch; |
| 122 | exports.setupRemote = setupRemote; |
nothing calls this directly
no test coverage detected
searching dependent graphs…