Skip to content

Commit 2b2c095

Browse files
committed
Remove useless head in diff
1 parent f10ce6b commit 2b2c095

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/run-prettier.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function runPrettier(
104104

105105
const fileLinkPrefix = `https://github.com/${repository.repository}/tree/${repository.commit}/`;
106106

107-
const { stdout: diff } = await spawn(
107+
let { stdout: diff } = await spawn(
108108
"git",
109109
[
110110
"diff",
@@ -116,6 +116,21 @@ export async function runPrettier(
116116
{ cwd: directory },
117117
);
118118

119+
// Remove the useless head
120+
const lines = diff.split("\n");
121+
for (let lineIndex = lines.length - 1; lineIndex > 0; lineIndex--) {
122+
if (
123+
lines[lineIndex].startsWith("diff --git Original|") &&
124+
lines[lineIndex + 1].startsWith("index ") &&
125+
lines[lineIndex + 2].startsWith("--- Original|http://github.com/") &&
126+
lines[lineIndex + 3].startsWith("+++ Alternative|")
127+
) {
128+
lines.splice(lineIndex, 2);
129+
}
130+
}
131+
132+
diff = lines.join("\n");
133+
119134
if (diff) {
120135
console.log(diff);
121136
}

0 commit comments

Comments
 (0)