首页 > 解决方案 > 如何以特定格式转换 git log --name-only?

问题描述

我想转换git log --name-only为特定格式。

的原始输出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

所需的转换应如下所示:

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

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

...more

我目前在java编程语言方面做了几次不成功的尝试。也许 java 不是解决这个问题的正确编程语言。

任何提示或提示?或者更确切地说,你将如何解决这个问题?另一个查询git log --name-only --pretty=format:%an;给出了接近的结果,但并不完全正确。

有人可以帮我吗?

谢谢

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

输出看起来:

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

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


标签: git

解决方案


这是awk为了什么。

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

或者

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

用你想要的任何额外的换行符打印在那里。


推荐阅读