From c907049c0a57ce958d4f53b6ac6f589a6025456b Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 16 Jul 2025 14:07:33 -0400 Subject: [PATCH] build-integration-branch: allow setting git trailer on final commit After the last commit is made, provide a simple mechanism for adding git trailers to the commit message. The git trailers [1] are metadata that tools may make use of. In particular, we add a few of the trailers documented by ceph-build here [2] as well as allowing for arbitrary trailers for future changes (before this code can be updated), advanced trailer, or other unrelated purposes. [1] https://www.alchemists.io/articles/git_trailers [2] https://github.com/ceph/ceph-build/tree/main/ceph-trigger-build Signed-off-by: John Mulligan --- src/script/build-integration-branch | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/script/build-integration-branch b/src/script/build-integration-branch index c4e39fdd67a..48051c2cd33 100755 --- a/src/script/build-integration-branch +++ b/src/script/build-integration-branch @@ -52,6 +52,33 @@ def parse_args(): action="store_true", help="Don't add `{postfix}` to the branch name.", ) + parser.add_argument( + "--trailer", + action="append", + dest='trailers', + help="Allow user to set arbitrary git trailers on final commit.", + ) + parser.add_argument( + '--ceph-build-job', + action="append", + dest='trailers', + type=lambda v: f'CEPH-BUILD-JOB:{v}', + help="Set CEPH-BUILD-JOB trailer on final commit.", + ) + parser.add_argument( + '--distros', + action="append", + dest='trailers', + type=lambda v: f'DISTROS:{v}', + help="Set DISTROS trailer on final commit.", + ) + parser.add_argument( + '--archs', + action="append", + dest='trailers', + type=lambda v: f'ARCHS:{v}', + help="Set DISTROS trailer on final commit.", + ) parser.add_argument( "--repo", default=REPO, @@ -150,6 +177,12 @@ def main(): message = ('Exiting due to an unknown failure when pulling ' f'PR#{pr_number}') raise Exception(message) + if cli.trailers: + cmd = ['git', 'commit', '--am', '--no-edit'] + cmd.extend(f'--trailer={t}' for t in cli.trailers) + if call(cmd) != 0: + print('Failed to set git trailers!') + sys.exit(1) print('--- done. these PRs were included:') print('\n'.join(prtext).encode('ascii', errors='ignore').decode()) -- 2.39.5