public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] mklog.py: Add --commit option.
@ 2023-05-11  8:29 Robin Dapp
  2023-05-11 14:46 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Robin Dapp @ 2023-05-11  8:29 UTC (permalink / raw)
  To: gcc-patches, mliska

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(-)

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:
-- 
2.40.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mklog.py: Add --commit option.
  2023-05-11  8:29 [PATCH] mklog.py: Add --commit option Robin Dapp
@ 2023-05-11 14:46 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-05-11 14:46 UTC (permalink / raw)
  To: Robin Dapp, gcc-patches, mliska



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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-11 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11  8:29 [PATCH] mklog.py: Add --commit option Robin Dapp
2023-05-11 14:46 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).