git - 如何以特定格式转换 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
-----------------------------------------------------------------
解决方案
这是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'
用你想要的任何额外的换行符打印在那里。
推荐阅读
- momentjs - 如何在没有警告的情况下将日期“2019 年 4 月 2 日”格式化为“YYYY-MM-DD”?
- input - 如何验证材料输入中的输入文本长度?
- angular - Ionic 4:让表单随每个输入而自我更新
- archlinux - pgadmin4 显示 500(内部服务器错误)
- python - Python while 循环正在暂停
- python - 使用带有 Python 的数据库跟踪在线用户
- python - 无法安装聊天机器人库
- node.js - 如何捆绑 node js 和 express js 用于生产?
- html - 订购弹性物品
- numpy - 从二进制文件创建 2D numpy 数组?