rs6000: Parsing built-in input file, part 3 of 3
[official-gcc.git] / contrib / git-commit-mklog.py
blob9c59fb97809555f3d37cce9fb2fc8a77d69b4194
1 #!/usr/bin/env python3
3 # Copyright (C) 2020 Free Software Foundation, Inc.
5 # This file is part of GCC.
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.
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.
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.
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.
26 import argparse
27 import os
28 import subprocess
30 if __name__ == '__main__':
31 children_args = []
32 myenv = os.environ.copy()
34 parser = argparse.ArgumentParser(description='git-commit-mklog wrapped')
35 parser.add_argument('-b', '--pr-numbers', action='store',
36 type=lambda arg: arg.split(','), nargs='?',
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')
40 args, unknown_args = parser.parse_known_args()
42 myenv['GCC_FORCE_MKLOG'] = '1'
43 mklog_args = []
44 if args.pr_numbers:
45 mklog_args.append(f'-b {",".join(args.pr_numbers)}')
46 if args.fill_up_bug_titles:
47 mklog_args.append('-p')
49 if mklog_args:
50 myenv['GCC_MKLOG_ARGS'] = ' '.join(mklog_args)
52 commit_args = ' '.join(unknown_args)
53 subprocess.run(f'git commit {commit_args}', shell=True, env=myenv)