]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
build-integration-branch: allow setting git trailer on final commit
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 16 Jul 2025 18:07:33 +0000 (14:07 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 16 Jul 2025 18:36:43 +0000 (14:36 -0400)
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 <jmulligan@redhat.com>
src/script/build-integration-branch

index c4e39fdd67a1493a5efdfbf462b9a489ba6efa46..48051c2cd33f59c993d7719a99d3a0073df2441b 100755 (executable)
@@ -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())