mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
Handle multiline commit messages when creating PR (#149426)
- This makes the body of the pull request non-empty when the commit message consists more than one line. - The GitHub web client fills the body the same way, too, when you create a pull request. - Some commit messages consist more than one line, like this one, which is giving more detail about the commit, and can be used as a shortcut to not write the same text when opening a pull request and on GitHub. - Without these changes, the pull request title will be messed up if the commit message is similar to this. Co-authored-by: João Moreno <joao.moreno@microsoft.com>
This commit is contained in:
@@ -102,13 +102,14 @@ async function handlePushError(repository: Repository, remote: Remote, refspec:
|
||||
let title = `Update ${remoteName}`;
|
||||
const head = repository.state.HEAD?.name;
|
||||
|
||||
let body: string | undefined;
|
||||
|
||||
if (head) {
|
||||
const commit = await repository.getCommit(head);
|
||||
title = commit.message.replace(/\n.*$/m, '');
|
||||
title = commit.message.split('\n')[0];
|
||||
body = commit.message.slice(title.length + 1).trim();
|
||||
}
|
||||
|
||||
let body: string | undefined;
|
||||
|
||||
const templates = await findPullRequestTemplates(repository.rootUri);
|
||||
if (templates.length > 0) {
|
||||
templates.sort((a, b) => a.path.localeCompare(b.path));
|
||||
|
||||
Reference in New Issue
Block a user