MCPcopy Index your code
hub / github.com/ampproject/amphtml / diffTentative

Function diffTentative

build-system/common/diff.js:15–27  ·  view source on GitHub ↗
(filepath, content, gitDiffFlags = ['-U1'])

Source from the content-addressed store, hash-verified

13 * @return {!Promise<string>}
14 */
15const diffTentative = (filepath, content, gitDiffFlags = ['-U1']) =>
16 tempy.write.task(content, (temporary) =>
17 getStdout(
18 [
19 'git -c color.ui=always diff',
20 ...gitDiffFlags,
21 filepath,
22 temporary,
23 ].join(' ')
24 )
25 .trim()
26 .replace(new RegExp(temporary, 'g'), `/${filepath}`)
27 );
28
29/**
30 * Diffs a file against new content.

Callers 1

writeDiffOrFailFunction · 0.85

Calls 3

getStdoutFunction · 0.85
taskMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected