Put long text values on their own line in commit descriptions

Summary:
We had a small bug where summary/test plans with leading spaces were getting their spaces stripped on Diffs. The leading spaces make it to the commit message, but when submitt, it gets confused by having the leading spaces on the same line:

```
these (<--) leading spaces are ignored
```

The fix is to have the "Summary:" tag be on its own line, like:
```

        these (<---) leading spaces are not ignored anymore
```

Reviewed By: quark-zju

Differential Revision: D59028642

fbshipit-source-id: 6b134a85c761cbe274bdf978e20c166b974e1fda
This commit is contained in:
Evan Krause 2024-06-26 13:34:07 -07:00 committed by Facebook GitHub Bot
parent e89e6a7bb4
commit 44f482b5b4
3 changed files with 6 additions and 6 deletions

View File

@ -112,9 +112,9 @@ export function commitMessageFieldsToString(
return schema
.filter(config => config.key === 'Title' || isFieldNonEmpty(fields[config.key]))
.map(config => {
const sep = config.type === 'field' ? ': ' : ':\n'; // long fields have keys on their own line, but fields can use the same line
// stringified messages of the form Key: value, except the title or generic description don't need a label
const prefix =
config.key === 'Title' || config.key === 'Description' ? '' : config.key + ': ';
const prefix = config.key === 'Title' || config.key === 'Description' ? '' : config.key + sep;
if (config.key === 'Title') {
const value = fields[config.key] as string;

View File

@ -567,7 +567,7 @@ describe('CommitInfoView', () => {
succeedableRevset('a'),
'--message',
expect.stringMatching(
/^My Commit hello new title\n+Summary: First commit in the stack\nhello new text/,
/^My Commit hello new title\n+(Summary:\s+)?First commit in the stack\nhello new text/,
),
],
id: expect.anything(),
@ -637,7 +637,7 @@ describe('CommitInfoView', () => {
'--addremove',
'--message',
expect.stringMatching(
/^Head Commit hello new title\n+Summary: stacked commit\nhello new text/,
/^Head Commit hello new title\n+(Summary:\s+)?stacked commit\nhello new text/,
),
],
id: expect.anything(),
@ -872,7 +872,7 @@ describe('CommitInfoView', () => {
'commit',
'--addremove',
'--message',
expect.stringMatching(/^new commit title\n+(Summary: )?my description/),
expect.stringMatching(/^new commit title\n+(Summary:\s+)?my description/),
],
id: expect.anything(),
runner: CommandRunner.Sapling,

View File

@ -420,7 +420,7 @@ describe('Image upload inside TextArea ', () => {
operation: expect.objectContaining({
args: expect.arrayContaining([
'commit',
expect.stringMatching('hi\n+(Summary: )?hey\nhttps://image.example.com/1111'),
expect.stringMatching('hi\n+(Summary:\n)?hey\nhttps://image.example.com/1111'),
]),
}),
}),