Paul Sokolovsky | 7371798 | 2022-12-28 19:51:47 +0300 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (c) 2022 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | |
| 7 | # Script to prepare a textual body of a comment to pass on the command line |
| 8 | # to Gerrit: limit it to acceptable size and quote properly. |
| 9 | |
| 10 | import sys |
| 11 | import shlex |
| 12 | |
| 13 | |
| 14 | SIZE_LIMIT = 16000 |
| 15 | |
| 16 | |
| 17 | body = "" |
| 18 | |
| 19 | with open(sys.argv[1], "r") as f: |
| 20 | for l in f: |
| 21 | body += l |
| 22 | if len(body) >= SIZE_LIMIT: |
| 23 | body += """\ |
| 24 | [...] |
| 25 | |
| 26 | WARNING: The report was trimmed due to size limit of a Gerrit comment. |
| 27 | Follow the link at the beginning to see the full report. |
| 28 | """ |
| 29 | break |
| 30 | |
| 31 | sys.stdout.write(shlex.quote(body)) |