* Build a unified diff that adds a brand-new file. Synthetic but realistic.
(filePath, contents)
| 263 | * Build a unified diff that adds a brand-new file. Synthetic but realistic. |
| 264 | */ |
| 265 | function newFileDiff(filePath, contents) { |
| 266 | const lines = contents.split("\n"); |
| 267 | // Strip trailing empty element produced by a terminating "\n" so the |
| 268 | // hunk header line count matches what git apply expects. |
| 269 | if (lines[lines.length - 1] === "") lines.pop(); |
| 270 | const body = lines.map(l => "+" + l).join("\n"); |
| 271 | return `diff --git a/${filePath} b/${filePath}\n` + `new file mode 100644\n` + `index 0000000..1111111\n` + `--- /dev/null\n` + `+++ b/${filePath}\n` + `@@ -0,0 +1,${lines.length} @@\n` + body + "\n"; |
| 272 | } |
| 273 | |
| 274 | it("checks out the requested branch and commits the patch on it (create_pull_request)", async () => { |
| 275 | const workspace = makeTempDir("gh-aw-prestage-cpr-"); |
no outgoing calls
no test coverage detected