MCPcopy
hub / github.com/ampproject/amphtml / affectsWorkingTree

Function affectsWorkingTree

build-system/tasks/make-extension/index.js:311–328  ·  view source on GitHub ↗

* @param {function():?{modified: ?Array , created: ?Array }} fn * @return {Promise}

(fn)

Source from the content-addressed store, hash-verified

309 * @return {Promise}
310 */
311async function affectsWorkingTree(fn) {
312 const stashStdout = getStdout(`git stash push --keep-index`);
313
314 const {created, modified} = (await fn()) || {};
315
316 if (created) {
317 await del(created);
318 }
319
320 if (modified) {
321 const head = getStdout('git rev-parse HEAD').trim();
322 getOutput(`git checkout ${head} ${modified.join(' ')}`);
323 }
324
325 if (!stashStdout.startsWith('No local changes')) {
326 getOutput('git stash pop');
327 }
328}
329
330/**
331 * Generates an extension with the given name and runs all unit tests located in

Callers

nothing calls this directly

Calls 3

getStdoutFunction · 0.85
fnFunction · 0.50
getOutputFunction · 0.50

Tested by

no test coverage detected