Blame maint/git-conflicts.bash
|
Packit Service |
c5cf8c |
#! /bin/bash
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
max_abbrev=12
|
|
Packit Service |
c5cf8c |
scale=10
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
total=`git rev-list --all | wc -l`
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
echo "Conflicts:"
|
|
Packit Service |
c5cf8c |
echo "Format: [abbrev length]: number of conflicts / total number of refs (percentage conflicts)"
|
|
Packit Service |
c5cf8c |
for ((x = 1 ; x <= ${max_abbrev} ; x++)) ; do
|
|
Packit Service |
c5cf8c |
conflicts=`git rev-list --all --abbrev=$x --abbrev-commit | sort | uniq -D -w$x | wc -l`
|
|
Packit Service |
c5cf8c |
percent=`echo "scale=$scale ; 100 * $conflicts / $total" | bc | awk '{ printf("%1.2f\n", $0); }'`
|
|
Packit Service |
c5cf8c |
echo " [$x]: $conflicts / $total ($percent %)"
|
|
Packit Service |
c5cf8c |
if test "$conflicts" = "0" ; then break ; fi
|
|
Packit Service |
c5cf8c |
done
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
##
|
|
Packit Service |
c5cf8c |
## probability calculation is based on this random link, that I found
|
|
Packit Service |
c5cf8c |
## online:
|
|
Packit Service |
c5cf8c |
## http://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/
|
|
Packit Service |
c5cf8c |
##
|
|
Packit Service |
c5cf8c |
## I have not verified the accuracy of the calculation at that link,
|
|
Packit Service |
c5cf8c |
## but if it is online, it must be true, of course. ;-)
|
|
Packit Service |
c5cf8c |
##
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
min_abbrev=$x
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
echo
|
|
Packit Service |
c5cf8c |
echo "Probability of collision on your next commit:"
|
|
Packit Service |
c5cf8c |
echo "Format: [abbrev length]: probability of collision"
|
|
Packit Service |
c5cf8c |
for ((x = ${min_abbrev}; x <= ${max_abbrev} ; x++)) ; do
|
|
Packit Service |
c5cf8c |
percent=`echo "scale=$scale ; 100 * ($total) / (16 ^ $x)" | bc | awk '{ printf("%1.4f\n", $0); }'`
|
|
Packit Service |
c5cf8c |
echo " [$x]: $percent %"
|
|
Packit Service |
c5cf8c |
done
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
commits_last_year=`git rev-list --all --since="1 year ago" | wc -l`
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
echo
|
|
Packit Service |
c5cf8c |
echo "Probability of collision in the next year (based on commits last year):"
|
|
Packit Service |
c5cf8c |
echo "Format: [abbrev length]: probability of collision"
|
|
Packit Service |
c5cf8c |
for ((x = ${min_abbrev}; x <= ${max_abbrev} ; x++)) ; do
|
|
Packit Service |
c5cf8c |
percent=`echo "scale=$scale ; 100 * (1 - ((1 - ($total / (16 ^ $x))) ^ ${commits_last_year}))" | bc | awk '{ printf("%1.4f\n", $0); }'`
|
|
Packit Service |
c5cf8c |
echo " [$x]: $percent %"
|
|
Packit Service |
c5cf8c |
done
|