mklog.py: Add --commit option.
Checks
Commit Message
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.
---
contrib/mklog.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
Comments
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
@@ -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: