Git日志JSON *更改文件* [英] Git log JSON *with changed files*

查看:145
本文介绍了Git日志JSON *更改文件*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取格式为JSON的git log命令的输出。我喜欢将Git日志输出为XML,JSON或YAML ?使用命令 here:

I need to get the output of a git log command formatted as JSON. I like the approach suggested in Git log output to XML, JSON, or 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=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/},]/}]/'

对于获取这些特定字段非常有用,但我还需要使用JSON输出中包含的--name-status标志返回的已更改文件的列表。

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.

我尝试了各种方法,但我在如何解决这个问题上感到不知所措。我的直觉告诉我我失去了一些明显的东西。任何想法?

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?

谢谢!

推荐答案

code> - 仅限名称参数支持原始Noah Sussman的脚本,以便您可以使用此命令获取已更改文件的列表:

I've added --name-only parameter support to the original Noah Sussman's script so you can get the list of changed files using this command:

git log2json --name-only

修正脚本此处

这篇关于Git日志JSON *更改文件*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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