-
Notifications
You must be signed in to change notification settings - Fork 0
/
prototype
72 lines (62 loc) · 2.94 KB
/
prototype
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# git for-each-ref --sort="-committerdate" --format="%(refname)" refs/remotes | xargs --verbose -n 1 -i git --no-pager diff --name-only "HEAD...{}"
# git branch -r --no-merged | xargs -n 1 -i git --no-pager whatchanged --since=yesterday --source -1 "HEAD..{}" --
# Get files modified in branches updated today
rm -f thisids.txt thisfiles.txt thisbranch.txt
git for-each-ref --sort="-committerdate" --format="%(committerdate:short) %(refname)" refs/remotes | grep `date -d yesterday +%Y-%m-%d` | awk '{print $2}' | while read thisbranch; do
git --no-pager diff --name-only master...$thisbranch -- *.java | while read thisfile; do
thispatchid=`git diff master...$thisbranch -- $thisfile | git patch-id`
echo $thisbranch $thispatchid $thisfile >> thisids.txt
echo $thisfile >> thisfiles.txt
done
echo $thisbranch >> thisbranch.txt
done
if [ ! -e thisids.txt -o ! -e thisbranch.txt ]; then exit 0; fi # shortcircuit, nothing to do
sort thisfiles.txt | uniq > thisfiles.tmp
mv thisfiles.tmp thisfiles.txt
# Get branches unmerged that are not stale
git branch -r --no-merged master | xargs -n 1 git log -1 --oneline --source --since=two.weeks.ago | awk '{print $2}' > thosebranches.txt
rm -rf branches
while read thatbranch; do
git --no-pager diff --name-only master...$thatbranch -- *.java | while read thatfile; do
mkdir -p branches/$thatfile
echo $thatbranch >> branches/$thatfile/branches.txt
done
done < thosebranches.txt
# Get files modified in unmerged branches
rm -f thoseids.txt
while read thisfile; do
while read thatbranch; do
thatpatchid=`git --no-pager diff master...$thatbranch -- $thisfile | git patch-id`
if [ ! -z "$thatpatchid" ]; then
echo $thisfile $thatpatchid $thatbranch >> thoseids.txt
fi
done < branches/$thisfile/branches.txt
done < thisfiles.txt
rm -rf refs
for i in `cat thisbranch.txt`; do
mkdir -p $i
done
awk '{
branch=$1
id=$2
file=$4
printf("grep \"%s\" thoseids.txt | grep -v %s | cut -d\" \" -f1,4 >> %s/conflicts.txt\n", file, id, branch)
}' thisids.txt | bash
find refs -type f -name conflicts.txt | xargs --verbose -n 1 cat
find refs -type f -name conflicts.txt -size 0 | xargs rm -f
rm -f emailbody.txt
cat thisbranch.txt | while read conflictbranch; do
if [ -e $conflictbranch/conflicts.txt ]; then
echo "==CONFLICTSET==" >> emailbody.txt
echo `dirname ${conflictbranch#refs/remotes/*}` >> emailbody.txt
echo "==SUMMARY==" >> emailbody.txt
echo "in ${conflictbranch#refs/remotes/*} with " >> emailbody.txt
cat $conflictbranch/conflicts.txt | awk '{print $2}' | sort | uniq >> emailbody.txt
echo "==DETAILS==" >> emailbody.txt
awk '{print $1}' $conflictbranch/conflicts.txt | sort | uniq | while read conflictfile; do
grep $conflictfile $conflictbranch/conflicts.txt | head -20 | awk -v f=$conflictfile 'BEGIN {b=sprintf("%s:",f)} {b=sprintf("%s %s", b, $2)} END {print b}' >> emailbody.txt
echo "--DETAIL--" >> emailbody.txt
done
fi
done
cat emailbody.txt