diff options
author | 2022-03-13 20:27:40 +0800 | |
---|---|---|
committer | 2022-03-13 20:27:40 +0800 | |
commit | 8e0184a05e1bd61d818477afffbecff029c5b585 (patch) | |
tree | 1cac0824ad248b0d01676c040edd740454ee8473 /source/features/use-first-commit-message-for-new-prs.tsx | |
parent | a199f1ea149532cb0ba58ec32b5f8d14ef4607a3 (diff) | |
download | refined-github-8e0184a05e1bd61d818477afffbecff029c5b585.tar.gz refined-github-8e0184a05e1bd61d818477afffbecff029c5b585.tar.zst refined-github-8e0184a05e1bd61d818477afffbecff029c5b585.zip |
Don't override the PR title and body provided via URL parameters (#5495)
Diffstat (limited to 'source/features/use-first-commit-message-for-new-prs.tsx')
-rw-r--r-- | source/features/use-first-commit-message-for-new-prs.tsx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/features/use-first-commit-message-for-new-prs.tsx b/source/features/use-first-commit-message-for-new-prs.tsx index a2272e4e..45398538 100644 --- a/source/features/use-first-commit-message-for-new-prs.tsx +++ b/source/features/use-first-commit-message-for-new-prs.tsx @@ -25,6 +25,7 @@ function getFirstCommitMessage(): string[] { } async function init(): Promise<void | false> { + const requestedContent = new URL(location.href).searchParams; const commitCountIcon = await elementReady('div.Box.mb-3 .octicon-git-commit'); const commitCount = commitCountIcon?.nextElementSibling; if (!commitCount || looseParseInt(commitCount) < 2 || !select.exists('#new_pull_request')) { @@ -32,14 +33,19 @@ async function init(): Promise<void | false> { } const [prTitle, ...prBody] = getFirstCommitMessage(); - textFieldEdit.set( - select('.discussion-topic-header input')!, - prTitle, - ); - textFieldEdit.insert( - select('#new_pull_request textarea[aria-label="Comment body"]')!, - prBody.join('\n\n'), - ); + if (!requestedContent.has('pull_request[title]')) { + textFieldEdit.set( + select('.discussion-topic-header input')!, + prTitle, + ); + } + + if (!requestedContent.has('pull_request[body]')) { + textFieldEdit.insert( + select('#new_pull_request textarea[aria-label="Comment body"]')!, + prBody.join('\n\n'), + ); + } } void features.add(import.meta.url, { |