You can do the following :
function getcommit { \
git show --pretty="format:" --name-only $1 | \
perl -pe's/^\n//g;' | \
sed 's/\(.*\)/"\1"/g' | \
perl -0pe 's/\n(?!\Z)/,\n/g'; \
}
export -f getcommit
git log -1 --pretty=format:'{%n "commit": "%H",%n "author": "%an <%ae>",%n "date": "%ad",%n "message": "%f",%n "files": [ COMMIT_HASH_%H ]%n},' | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/;s/COMMIT_HASH_(\w+)/`echo -n "";getcommit $1`/e'
Basically, I replaced commit hash with a fixed string COMMIT_HASH_
preceding the hash itself and then replace this hash with the result of git show --pretty="format:" --name-only $COMMIT_HASH
.
All changed file are put into a json array "files". This is working for the last X commit
Here is an example for the 2 last commit :
[{
"commit": "1edcef90b42afee11fbd31dcc458ae0f15a3bb6e",
"author": "Bertrand Martel <......@gmail.com>",
"date": "Tue Oct 13 17:35:34 2015 +0200",
"message": "update-readme",
"files": [ "README.md",
"device.png",
"screenshot.png"
]
},
{
"commit": "8aa2ce64e58b770122a3561b8ef41d807ce36abc",
"author": "Bertrand Martel <......@gmail.com>",
"date": "Mon Oct 12 19:36:18 2015 +0200",
"message": "fix-async-bluetooth-command-bug-bluetoooth-state-check",
"files": [ "android/app/src/main/java/fr/bmartel/android/bluetooth/BluetoothCustomManager.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/GattTask.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/GattUtils.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/IBluetoothCustomManager.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/IBluetoothManagerEventListener.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/ICharacteristicListener.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/IDevice.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/IDeviceInitListener.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/IScanListListener.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/connection/BluetoothDeviceAbstr.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/connection/BluetoothDeviceConn.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/connection/IBluetoothDeviceConn.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/listener/IPushListener.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/notti/INottiDevice.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/notti/INottiListener.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/notti/NottiDevice.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/shared/ActionFilterGatt.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/shared/ISharedActivity.java",
"android/app/src/main/java/fr/bmartel/android/bluetooth/shared/LeDeviceListAdapter.java",
"android/app/src/main/java/fr/bmartel/android/notti/NottiActivity.java",
"android/app/src/main/java/fr/bmartel/android/notti/NottiBtService.java",
"android/app/src/main/java/fr/bmartel/android/notti/NottiDeviceActivity.java"
]
}]
Here is a script that take commit index in parameters and return json info including files changed : https://gist.github.com/bertrandmartel/a4ed5d76562e74d77282