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

Function assertContentsMatch

test/helper.js:90–119  ·  view source on GitHub ↗

* @param {string} dir The dir. * @param {string} url The url. * @param {string} branch The branch. * @return {Promise} A promise.

(dir, url, branch)

Source from the content-addressed store, hash-verified

88 * @return {Promise} A promise.
89 */
90function 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
121exports.assertContentsMatch = assertContentsMatch;
122exports.setupRemote = setupRemote;

Callers

nothing calls this directly

Calls 1

mkdtempFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…