2020-10-31 16:31:28 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#
|
|
|
|
# author {
|
|
|
|
# name "kuesji koesnu"
|
|
|
|
# email "kuesji@koesnu.com"
|
|
|
|
# website "kuesji.koesnu.com"
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SINCE=$(date +%s --date="-1 month")
|
|
|
|
TEXT='Translated using Weblate'
|
|
|
|
INPUT_FILE=""
|
2020-11-01 07:17:20 -06:00
|
|
|
CSV_FILE=""
|
2020-10-31 16:31:28 -05:00
|
|
|
OUTPUT_FILE=""
|
|
|
|
|
|
|
|
set -ef
|
|
|
|
|
|
|
|
print_help(){
|
|
|
|
usage='
|
|
|
|
options
|
|
|
|
--full generate translator list from beginning ( only last month generated without this )
|
|
|
|
-i file give input file for previous contributors
|
|
|
|
-o file give output file for latest contributors list including previous
|
2020-11-01 07:17:20 -06:00
|
|
|
--csv file give input from csv file
|
2020-10-31 16:31:28 -05:00
|
|
|
'
|
|
|
|
|
|
|
|
echo "$usage"
|
|
|
|
}
|
|
|
|
|
|
|
|
find_hashs(){
|
2020-11-01 07:17:20 -06:00
|
|
|
# if since is greater than 0 take last month's authors else full
|
|
|
|
if [ "$SINCE" -gt 0 ]
|
|
|
|
then
|
|
|
|
git log --since="$SINCE" --pretty=format:"%h %s" --grep="$TEXT" | cut -d ' ' -f1
|
|
|
|
else
|
|
|
|
git log --pretty=format:"%h %s" --grep="$TEXT" | cut -d ' ' -f1
|
|
|
|
fi
|
2020-10-31 16:31:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
collect_authors(){
|
|
|
|
for hash in $(find_hashs)
|
|
|
|
do
|
2020-11-01 07:17:20 -06:00
|
|
|
info=$(git show "$hash" --pretty=format:'%an' | head -n 1)
|
2020-10-31 16:31:28 -05:00
|
|
|
echo $info
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# show help if no argument passed
|
|
|
|
if [ $# -lt 1 ]
|
|
|
|
then
|
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# parsing arguments
|
|
|
|
while [ $# -gt 1 ];
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
'--full')
|
2020-11-01 07:17:20 -06:00
|
|
|
shift; SINCE="0";
|
2020-10-31 16:31:28 -05:00
|
|
|
;;
|
|
|
|
'-i')
|
|
|
|
shift; INPUT_FILE="$1"; shift;
|
|
|
|
;;
|
|
|
|
'-o')
|
|
|
|
shift; OUTPUT_FILE="$1"; shift;
|
|
|
|
;;
|
2020-11-01 07:17:20 -06:00
|
|
|
'--csv')
|
|
|
|
shift; CSV_FILE="$1"; shift;
|
|
|
|
;;
|
2020-10-31 16:31:28 -05:00
|
|
|
*)
|
|
|
|
shift;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# we need an output list
|
|
|
|
if [ -z "$OUTPUT_FILE" ]
|
|
|
|
then
|
|
|
|
echo 'error: please give output file with "-o filename" format' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# read input list if given
|
|
|
|
if [ ! -z "$INPUT_FILE" ] && [ -f "$INPUT_FILE" ]
|
|
|
|
then
|
|
|
|
cat "$INPUT_FILE" > 'tmp.txt'
|
|
|
|
fi
|
2020-11-01 07:17:20 -06:00
|
|
|
|
|
|
|
# load csv if csv file given
|
|
|
|
if [ ! -z "$CSV_FILE" ] && [ -f "$CSV_FILE" ]
|
|
|
|
then
|
|
|
|
# backup and switch delimiter to comma
|
|
|
|
OLDIFS="$IFS"
|
|
|
|
IFS=','
|
|
|
|
for author in $( cat "$CSV_FILE" )
|
|
|
|
do
|
|
|
|
# first remove leading spaces, second sed trim trailing space
|
|
|
|
echo "$author" | sed 's,^ *,,g' | sed 's, *$,,g' >> 'tmp.txt'
|
|
|
|
done
|
|
|
|
# restore old delimitier
|
|
|
|
IFS="$OLDIFS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-31 16:31:28 -05:00
|
|
|
# generate latest list and combine
|
|
|
|
collect_authors >> 'tmp.txt'
|
|
|
|
# read all, sort all, make unique and write to output file
|
|
|
|
cat 'tmp.txt' | sort | uniq > "$OUTPUT_FILE"
|
2020-11-01 08:20:51 -06:00
|
|
|
|
|
|
|
if [ ! -z "$CSV_FILE" ]
|
|
|
|
then
|
|
|
|
# put a comma on end of every line
|
|
|
|
sed -e 's/$/,/g' "$OUTPUT_FILE" > 'tmp.txt'
|
|
|
|
# delete newline characters
|
|
|
|
cat tmp.txt | tr -d '\n' > "$OUTPUT_FILE"
|
|
|
|
fi
|
|
|
|
|
2020-10-31 16:31:28 -05:00
|
|
|
# thanks for service tmp.txt, but we dont need you anymore
|
|
|
|
rm 'tmp.txt'
|