forked from edwardbadboy/pydiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitpydiff
executable file
·32 lines (27 loc) · 845 Bytes
/
gitpydiff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/bash
diffDir=/tmp/pydiff
fileList="$diffDir"/filelist
mkdir -p "$diffDir"
git status --porcelain -uno | egrep '^\sM\s.+$' >/dev/null
modification=$(git diff; git diff --cached)
if [ "$modification" != "" ]; then
git status
echo
echo 'Error: Workspace or git index is not clean.' >&2
exit 1
fi
commitHead="$1"
if [ "$commitHead" == "" ]; then
commitHead=$(git log --pretty=format:%H -1 HEAD)
else
commitHead=$(git log --pretty=format:%H -1 "$commitHead")
fi
git checkout -q "$commitHead"
git show --pretty=format:"" --numstat | awk '/(\.py|\.py.in)$/{print $3}' >"$fileList"
cat "$fileList" | xargs -I{F} /usr/bin/cp -f --parents {F} "$diffDir"
git checkout -q "$commitHead"~1
cat "$fileList" | while read filePath; do
echo checking "$filePath"
pydiff "$filePath" "$diffDir"/"$filePath"
done
git checkout -q "$commitHead"