解析git日志输出,最好是xml [英] parsing git log output, preferably as xml

查看:138
本文介绍了解析git日志输出,最好是xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解析git log的输出。我目前的工具通过解析svn log具有的--xml选项来完成svn。我似乎无法弄清楚如何输出git日志为xml。如果xml不是一个选项,那么解析这个输出的最好方法是什么?我真的很想避免将它解析为原始文本,寻找作者和日期等。

谢谢

解决方案

使用格式化选项。

  git log --pretty = format:< entry>< author>%an<作者>< commit_date>%cd和LT; / commit_date>< MESSAGE_BODY>%b将/ MESSAGE_BODY>< /条目>中

只需添加您想要的任何字段即可。 (如果你想要正确的xml头文件,你需要编写脚本。)



请参阅 man git-log PRETTY FORMATS 部分可以访问的字段列表。


I want to parse the output from git log. My current tool does this for svn by parsing the --xml option that svn log has. I can't seem to figure out how to output git log as xml. If xml is not an option, what is the best way to parse this output? I would really like to avoid parsing it as raw text, looking for "author" and "date" ect.

thanks

解决方案

You could build your own simple xml output by using the formatting options.

git log --pretty=format:"<entry><author>%an</author><commit_date>%cd</commit_date><message_body>%b</message_body></entry>"

Just add whatever fields you want. (You'll need to script a bit if you want proper xml header etc.)

See man git-log PRETTY FORMATS section the list of fields you have access to.

这篇关于解析git日志输出,最好是xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆