I am trying to output GitHub history for a folder in JSON format, that contains author, date, comment and files affected (path). I can get all done but the files with the following command:
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/},]/}]/' >log.json
To get the file names --name-only could be used with the log command, but I can't really get it in the JSON as array or "files". Here is where I am now:
git log --name-only --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/},]/}]/' >log.json
This produces:
{
"commit": "GUID"
"author": "My name <my@email.com",
"date": "Mon May 29 15:42:58 2017 +0300",
"message": "commit comment"
},
/folder/subfolder/file.extention
/folder/file.extention
While I want the files specified as JSON array in the commit:
{
"commit": "GUID"
"author": "My name <my@email.com",
"date": "Mon May 29 15:42:58 2017 +0300",
"message": "commit comment"
"files": [
"/folder/subfolder/file.extention"
"/folder/file.extention" ]
},