Clean up Perforce change description rewriting and fix newline errors.

Review Request #13023 — Created May 8, 2023 and submitted — Latest diff uploaded

Information

RBTools
release-4.x

Reviewers

We've had code in the tree for a long while to stamp Perforce changes
with a review request URL, but it had a flaw. It left out a newline,
causing the first line to read:

Description:   Here is the first line.
        And here is the second line.

This was due to a missing newline after adding the "Description:" field.

This change fixes this up, reworks the logic and comments to be a bit
more clear about the states being kept and the newlines added, and adds
unit tests.

It also fixes up the amending portion, which didn't include a changenum
in the p4 change command (which meant it couldn't amend anything but
default).

A timeout is now set for the p4 change command, in case anything fails
during a hook script. Errors are outputted if anything goes wrong.

Unit tests passed.

Tested manually with updates to the trigger script.

Changes between revision 1 and 2

orig
1
2

Commits

Summary ID Author
Clean up Perforce change description rewriting and fix newline errors.
We've had code in the tree for a long while to stamp Perforce changes with a review request URL, but it had a flaw. It left out a newline, causing the first line to read: ``` Description: Here is the first line. And here is the second line. ``` This was due to a missing newline after adding the "Description:" field. This change fixes this up, reworks the logic and comments to be a bit more clear about the states being kept and the newlines added, and adds unit tests.
53e9a853d273c8b3516bec66b165bf9b7f144105 Christian Hammond
Clean up Perforce change description rewriting and fix newline errors.
We've had code in the tree for a long while to stamp Perforce changes with a review request URL, but it had a flaw. It left out a newline, causing the first line to read: ``` Description: Here is the first line. And here is the second line. ``` This was due to a missing newline after adding the "Description:" field. This change fixes this up, reworks the logic and comments to be a bit more clear about the states being kept and the newlines added, and adds unit tests. It also fixes up the amending portion, which didn't include a changenum in the `p4 change` command (which meant it couldn't amend anything but `default`). A timeout is now set for the `p4 change` command, in case anything fails during a hook script. Errors are outputted if anything goes wrong.
174b6711bb9995c787fbae0de53b8386947e8064 Christian Hammond
rbtools/clients/perforce.py
Loading...