Message ID | ada6da15-ba5e-1959-91ae-3ed9c44faf1f@gmail.com |
---|---|
State | New |
Headers | show |
Series | mklog.py: Add --commit option. | expand |
On 5/11/23 02:29, Robin Dapp via Gcc-patches wrote: > Hi, > > this patch allows mklog.py to be called with a commit hash directly. > So, instead of > > git show <commit> | git gcc-mklog > > git gcc-mklog --commit <commit> > > can be used. > > When no <commit> is given but --commit is specified, HEAD is used > instead. The behavior without --commit is the same as before. > > Is that useful/OK? I find that option a bit easier to work with. > > Regards > Robin > > contrib/ChangeLog: > > * mklog.py: Add optional --commit <commit> argument. Seems reasonable to me and probably works better with the flows some people are using :-) Jeff
diff --git a/contrib/mklog.py b/contrib/mklog.py index 777212c98d7..25a3b6c0757 100755 --- a/contrib/mklog.py +++ b/contrib/mklog.py @@ -358,13 +358,23 @@ if __name__ == '__main__': 'file') parser.add_argument('--update-copyright', action='store_true', help='Update copyright in ChangeLog files') + parser.add_argument('--commit', const='HEAD', nargs='?', + help='Use a specific commit instead of a ' + 'patch file or stdin. (essentially git show ' + 'commit-id | git gcc-mklog)') args = parser.parse_args() if args.input == '-': args.input = None if args.directory: root = args.directory - data = open(args.input, newline='\n') if args.input else sys.stdin + if args.commit: + args.input = None + data = subprocess.check_output('git show {}'.format(args.commit), + shell=True, encoding='utf8').strip() + else: + data = open(args.input, newline='\n') if args.input else sys.stdin + if args.update_copyright: update_copyright(data) else: