简体   繁体   中英

How to convert git log --name-only in a specific format?

I would like to convert git log --name-only in a specific format.

Original output of git log --name-only :

commit 565ad47821a7e3e6c95304143530e5e355b32e72
Author: Yu-Cheng Ling <ycling@google.com>
Date:   Wed Dec 18 23:15:49 2019 -0800

    Override experimental_new_converter is not None.

    PiperOrigin-RevId: 286335164
    Change-Id: I66793be1e5277425f6da6dd519b256e18d61d071

tensorflow/lite/python/tflite_convert.py
tensorflow/lite/python/tflite_convert_test.py

...more commits

The desired conversion should look as follows:

Yu-Cheng Ling,tensorflow/lite/python/tflite_convert.py

Yu-Cheng Ling,tensorflow/lite/python/tflite_convert_test.py

...more

I have currently made several unsuccessful attempts in java programming language. Maybe java is not the right programming language for this problem.

Any hints or tips? Or rather, how would you solve the problem? Another query git log --name-only --pretty=format:%an; gives a near resultat, but not completely correct.

Could someone please help me?

Thanks

Additional: git log --name-only --pretty=format:%an;

The output looks:

Yu-Cheng Ling;
tensorflow/lite/python/tflite_convert.py
tensorflow/lite/python/tflite_convert_test.py

A. Unique TensorFlower;
tensorflow/go/op/wrappers.go

TensorFlower Gardener;
Yunxing Dai;
tensorflow/compiler/xla/service/dynamic_dimension_inference.cc
tensorflow/compiler/xla/service/dynamic_dimension_inference.h
... more```



I still need to remove the line break and convert the output to:


-----------------------------------------------------------------
Yu-Cheng Ling,tensorflow/lite/python/tflite_convert.py

Yu-Cheng Ling,tensorflow/lite/python/tflite_convert_test.py

...more

-----------------------------------------------------------------


This is what awk is for.

git log --name-only --pretty=format:%an \
| awk ' /^$/ { del name; next }
        !name{ name = $0; next }
             { print name","$0 }
'

or

git log --name-only --pretty=format:%an \
| awk '{ for (n=1; n++<NF; ) print $1","$n }' RS= FS=$'\n'

with whatever extra newline printing you want sprinkled in there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM