Skip to content

Commit 59d9340

Browse files
committed
feat: add limit check and print diff output for --creat-issue command
1 parent 0b9b015 commit 59d9340

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/createIssue.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,19 @@ export function openIssueCreationLink({
9999
if (patchFileContents.endsWith("\n")) {
100100
patchFileContents = patchFileContents.slice(0, -1)
101101
}
102-
103-
open(
102+
103+
const bodyExceedsLimit = patchFileContents.length > 300;
104+
let diffContents = patchFileContents;
105+
if (bodyExceedsLimit) {
106+
diffContents = '<!-- 🔺️🔺️🔺️ PLEASE REPLACE THIS BLOCK with the diff contents printed out by the `--create-issue` command. 🔺️🔺️🔺️ -->';
107+
console.log(`📋 Copy the following diff contents and paste them into the issue diff section:
108+
109+
${patchFileContents}
110+
`);
111+
}
112+
113+
else {
114+
open(
104115
`https://github.com/${vcs.org}/${vcs.repo}/issues/new?${stringify({
105116
title: "",
106117
body: `Hi! 👋
@@ -114,11 +125,12 @@ Today I used [patch-package](https://github.com/ds300/patch-package) to patch \`
114125
Here is the diff that solved my problem:
115126
116127
\`\`\`diff
117-
${patchFileContents}
128+
${diffContents}
118129
\`\`\`
119130
120131
<em>This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).</em>
121132
`,
122133
})}`,
123134
)
135+
}
124136
}

0 commit comments

Comments
 (0)