mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
Improve 2 of the github scripts (#27493)
This commit is contained in:
@@ -3,37 +3,41 @@
|
||||
# Count number of different contributors and number of commits for a given year or month
|
||||
# Can be used for statistics (for example to generate the infography of the year)
|
||||
#
|
||||
# shellcheck disable=2027,2086,2268
|
||||
|
||||
PERIOD=$1
|
||||
STARTYEAR=$2
|
||||
ENDYEAR=$3
|
||||
|
||||
DEBUG=${DEBUG:=0} # Example: run script with DEBUG=1 script arguments
|
||||
|
||||
echo "***** github_authors_and_commits_bydate.sh *****"
|
||||
if [ "x$1" = "x" ]; then
|
||||
|
||||
if [ "$PERIOD" != "byyear" ] && [ "$PERIOD" != "bymonth" ] && [ "$PERIOD" != "byday" ]; then
|
||||
echo "Usage: $0 (byyear|bymonth|byday) YEARSTART [YEAREND]"
|
||||
exit
|
||||
fi
|
||||
if [ "x$1" != "xbyyear" -a "x$1" != "xbymonth" -a "x$1" != "xbyday" ]; then
|
||||
echo "Usage: $0 (byyear|bymonth|byday) YEARSTART [YEAREND]"
|
||||
exit
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Default is byyear
|
||||
DATEFORMAT="%Y"
|
||||
if [ "x$1" = "xbymonth" ]; then
|
||||
if [ "$PERIOD" = "bymonth" ]; then
|
||||
DATEFORMAT="%Y%m"
|
||||
fi
|
||||
if [ "x$1" = "xbyday" ]; then
|
||||
elif [ "$PERIOD" = "byday" ]; then
|
||||
DATEFORMAT="%Y%m%d"
|
||||
fi
|
||||
|
||||
FROM=$2-01-01
|
||||
TO=$2-12-31
|
||||
if [ "x$3" != "x" ]; then
|
||||
TO=$2-12-31
|
||||
FROM=${STARTYEAR}-01-01
|
||||
TO=${STARTYEAR}-12-31
|
||||
if [ "${ENDYEAR}" != "" ]; then
|
||||
TO=${ENDYEAR}-12-31
|
||||
else
|
||||
ENDYEAR=9999
|
||||
fi
|
||||
|
||||
echo "--- Number of different contributors for the year"
|
||||
echo "git log --use-mailmap --since $FROM --before $TO | iconv -f UTF-8 -t ASCII//TRANSLIT | grep ^Author | awk -F'<' '{ print $1 }' | sort -u -f -i -b | wc -l"
|
||||
git log --since $FROM --before $TO | iconv -f UTF-8 -t ASCII//TRANSLIT | grep '^Author' | awk -F"<" '{ print $1 }' | sort -u -f -i -b | wc -l
|
||||
echo "--- Number of different contributors for the period $FROM $TO"
|
||||
[ "$DEBUG" -ne 0 ] && echo "git log --use-mailmap --since '$FROM' --before '$TO' | iconv -f UTF-8 -t ASCII//TRANSLIT | grep ^Author | awk -F'<' '{ print $1 }' | sort -u -f -i -b | wc -l" >&2
|
||||
git log --since "$FROM" --before "$TO" | iconv -c -f UTF-8 -t ASCII//TRANSLIT | grep '^Author' | awk -F"<" '{ print $1 }' | sort -u -f -i -b | wc -l
|
||||
|
||||
|
||||
echo "--- Number of commit $1"
|
||||
echo "git log --use-mailmap --pretty='format:%cd' --date=format:'$DATEFORMAT' | iconv -f UTF-8 -t ASCII//TRANSLIT | sort | uniq -c | awk '{ if (\$2 >= '"$1"') { print \"Year: \"\$2\", commits: \"\$1 } }'"
|
||||
git log --pretty='format:%cd' --date=format:"$DATEFORMAT" | iconv -f UTF-8 -t ASCII//TRANSLIT | sort | uniq -c | awk '{ if ($2 >= '$1') { print "Year: "$2", commits: "$1 } }'
|
||||
echo "--- Number of commits $1"
|
||||
[ "$DEBUG" -ne 0 ] && echo "git log --use-mailmap --pretty='format:%cd' --date=format:'$DATEFORMAT' | iconv -f UTF-8 -t ASCII//TRANSLIT | sort | uniq -c | awk '{ if (\$2 >= '$1') { print \"Year: \"\$2\", commits: \"\$1 } }'" >&2
|
||||
git log --pretty='format:%cd' --date=format:"$DATEFORMAT" | iconv -f UTF-8 -t ASCII//TRANSLIT | sort | uniq -c | awk '{ if ($2 >= '"${STARTYEAR}"' && $2 <='"${ENDYEAR}"') { print "Year: "$2", commits: "$1 } }'
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#
|
||||
|
||||
# shellcheck disable=2002,2086,2268
|
||||
DEBUG=${DEBUG:=0}
|
||||
|
||||
if [ "x$2" = "x" ]; then
|
||||
if [ "$2" = "" ]; then
|
||||
echo "***** github_lines_perusers.sh *****"
|
||||
echo "Return the number of lines of code produced by each contributor between 2 versions"
|
||||
echo "Usage: $0 origin/branchstart|tagnamestart|START origin/branchend|tagnameend|HEAD"
|
||||
@@ -15,12 +16,13 @@ if [ "x$2" = "x" ]; then
|
||||
fi
|
||||
|
||||
START="$1.."
|
||||
if [ "x$START" = "xSTART.." ]; then
|
||||
END=$2
|
||||
if [ "$START" = "START.." ]; then
|
||||
START=""
|
||||
fi
|
||||
|
||||
echo "git log $START$2 --shortstat | grep ... | perl ... > /tmp/github_lines_perusers.tmp"
|
||||
git log $START$2 --shortstat --use-mailmap | iconv -f UTF-8 -t ASCII//TRANSLIT | grep -e 'Author:' -e 'Date:' -e ' changed' -e ' insertion' -e ' deletion' | perl -n -e '/^(.*)$/; $line = $1; if ($line =~ /(changed|insertion|deletion)/) { $line =~ s/[^0-9\s]//g; my @arr=split /\s+/, $line; $tot=0; for (1..@arr) { $tot += $arr[$_]; }; print $tot."\n"; } else { print $line."\n"; };' > /tmp/github_lines_perusers.tmp
|
||||
[ "$DEBUG" ] && echo "git log '${START}${END}' --shortstat | grep ... | perl ... > /tmp/github_lines_perusers.tmp"
|
||||
git log "${START}${END}" --shortstat --use-mailmap | iconv -f UTF-8 -t ASCII//TRANSLIT | grep -e 'Author:' -e 'Date:' -e ' changed' -e ' insertion' -e ' deletion' | perl -n -e '/^(.*)$/; $line = $1; if ($line =~ /(changed|insertion|deletion)/) { $line =~ s/[^0-9\s]//g; my @arr=split /\s+/, $line; $tot=0; for (1..@arr) { $tot += $arr[$_]; }; print $tot."\n"; } else { print $line."\n"; };' > /tmp/github_lines_perusers.tmp
|
||||
|
||||
echo "Users and nb of lines";
|
||||
cat /tmp/github_lines_perusers.tmp | awk 'BEGIN { FS="\n"; lastuser=""; } { if ($1 ~ /^Author:/) { sub(/<.*/, ""); lastuser=tolower($1) }; if ($1 ~ /^[0-9]+$/) { aaa[lastuser]+=$1; } } END { for (var in aaa) print var," ",aaa[var]; } ' | sort
|
||||
|
||||
Reference in New Issue
Block a user