]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/git-commit-mklog.py
Update copyright years.
[thirdparty/gcc.git] / contrib / git-commit-mklog.py
CommitLineData
c2124b51
ML
1#!/usr/bin/env python3
2
83ffe9cd 3# Copyright (C) 2020-2023 Free Software Foundation, Inc.
c2124b51
ML
4#
5# This file is part of GCC.
6#
7# GCC is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3, or (at your option)
10# any later version.
11#
12# GCC is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GCC; see the file COPYING. If not, write to
19# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20# Boston, MA 02110-1301, USA.
21#
22# The script is wrapper for git commit-mklog alias where it parses
23# -b/--pr-numbers argument and passes it via environment variable
24# to mklog.py script.
25
26import argparse
18ef76d3 27import json
c2124b51
ML
28import os
29import subprocess
30
31if __name__ == '__main__':
32 children_args = []
33 myenv = os.environ.copy()
34
35 parser = argparse.ArgumentParser(description='git-commit-mklog wrapped')
18ef76d3 36 parser.add_argument('-b', '--pr-numbers',
c2124b51
ML
37 help='Add the specified PRs (comma separated)')
38 parser.add_argument('-p', '--fill-up-bug-titles', action='store_true',
39 help='Download title of mentioned PRs')
0684c8d3
ML
40 parser.add_argument('--co',
41 help='Add Co-Authored-By trailer (comma separated)')
c2124b51
ML
42 args, unknown_args = parser.parse_known_args()
43
44 myenv['GCC_FORCE_MKLOG'] = '1'
45 mklog_args = []
46 if args.pr_numbers:
18ef76d3 47 mklog_args += ['-b', args.pr_numbers]
c2124b51
ML
48 if args.fill_up_bug_titles:
49 mklog_args.append('-p')
50
51 if mklog_args:
18ef76d3
ML
52 # wrap mklog arguments with JSON
53 myenv['GCC_MKLOG_ARGS'] = json.dumps(mklog_args)
c2124b51 54
0684c8d3
ML
55 if args.co:
56 for author in args.co.split(','):
57 unknown_args.append(f'--trailer "Co-Authored-By: {author}"')
58
c2124b51
ML
59 commit_args = ' '.join(unknown_args)
60 subprocess.run(f'git commit {commit_args}', shell=True, env=myenv)