Skip to content

Commit c907049

Browse files
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 <[email protected]>
1 parent 5ce45a2 commit c907049

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/script/build-integration-branch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,33 @@ def parse_args():
5252
action="store_true",
5353
help="Don't add `{postfix}` to the branch name.",
5454
)
55+
parser.add_argument(
56+
"--trailer",
57+
action="append",
58+
dest='trailers',
59+
help="Allow user to set arbitrary git trailers on final commit.",
60+
)
61+
parser.add_argument(
62+
'--ceph-build-job',
63+
action="append",
64+
dest='trailers',
65+
type=lambda v: f'CEPH-BUILD-JOB:{v}',
66+
help="Set CEPH-BUILD-JOB trailer on final commit.",
67+
)
68+
parser.add_argument(
69+
'--distros',
70+
action="append",
71+
dest='trailers',
72+
type=lambda v: f'DISTROS:{v}',
73+
help="Set DISTROS trailer on final commit.",
74+
)
75+
parser.add_argument(
76+
'--archs',
77+
action="append",
78+
dest='trailers',
79+
type=lambda v: f'ARCHS:{v}',
80+
help="Set DISTROS trailer on final commit.",
81+
)
5582
parser.add_argument(
5683
"--repo",
5784
default=REPO,
@@ -150,6 +177,12 @@ def main():
150177
message = ('Exiting due to an unknown failure when pulling '
151178
f'PR#{pr_number}')
152179
raise Exception(message)
180+
if cli.trailers:
181+
cmd = ['git', 'commit', '--am', '--no-edit']
182+
cmd.extend(f'--trailer={t}' for t in cli.trailers)
183+
if call(cmd) != 0:
184+
print('Failed to set git trailers!')
185+
sys.exit(1)
153186

154187
print('--- done. these PRs were included:')
155188
print('\n'.join(prtext).encode('ascii', errors='ignore').decode())

0 commit comments

Comments
 (0)