[英]Git log JSON *with changed files*
I need to get the output of a git log command formatted as JSON. 我需要获取git log命令的输出,格式为JSON。 I like the approach suggested in Git log output to XML, JSON, or YAML?
我喜欢Git日志输出到XML,JSON或YAML中建议的方法吗? to use a custom git log pretty formatter and a light layer of perl processing on top using the command here :
在此处使用以下命令使用自定义git log pretty formatter和perl处理的轻层:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%an <%ae>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
This works fantastic for getting those certain fields, but I also need the list of files changed that is returned from using the --name-status flag included in the JSON output. 这对于获取那些特定字段非常有用,但我还需要使用JSON输出中包含的--name-status标志返回的已更改文件列表。
I've tried various approaches but I'm at a loss at how to approach this. 我尝试了各种方法,但是如何处理却迷茫了。 My gut tells me I'm missing something obvious.
我的直觉告诉我,我缺少明显的东西。 Any ideas?
有任何想法吗?
Thanks! 谢谢!
I know little about Perl. 我对Perl知之甚少。 Here is my way to get the changed files of a commit.
这是我获取提交的更改文件的方法。 Hope it helps.
希望能帮助到你。
git log -1 <sha1> --pretty=%h --name-only | tail -n +3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.