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(){
|
2020-11-01 13:32:34 -06:00
|
|
|
usage='
|
2020-10-31 16:31:28 -05:00
|
|
|
options
|
2020-11-01 13:32:34 -06:00
|
|
|
--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
|
|
|
|
--csv file give input from csv file
|
|
|
|
'
|
2020-10-31 16:31:28 -05:00
|
|
|
|
2020-11-01 13:32:34 -06:00
|
|
|
echo "$usage"
|
2020-10-31 16:31:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
find_hashs(){
|
2020-11-01 13:32:34 -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(){
|
2020-11-01 13:32:34 -06:00
|
|
|
for hash in $(find_hashs)
|
|
|
|
do
|
|
|
|
info=$(git show "$hash" --pretty=format:'%an' | head -n 1)
|
|
|
|
echo $info
|
|
|
|
done
|
2020-10-31 16:31:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# show help if no argument passed
|
|
|
|
if [ $# -lt 1 ]
|
|
|
|
then
|
2020-11-01 13:32:34 -06:00
|
|
|
print_help
|
|
|
|
exit 1
|
2020-10-31 16:31:28 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# parsing arguments
|
|
|
|
while [ $# -gt 1 ];
|
|
|
|
do
|
2020-11-01 13:32:34 -06:00
|
|
|
case "$1" in
|
|
|
|
'--full')
|
|
|
|
shift; SINCE="0";
|
|
|
|
;;
|
|
|
|
'-i')
|
|
|
|
shift; INPUT_FILE="$1"; shift;
|
|
|
|
;;
|
|
|
|
'-o')
|
|
|
|
shift; OUTPUT_FILE="$1"; shift;
|
|
|
|
;;
|
|
|
|
'--csv')
|
|
|
|
shift; CSV_FILE="$1"; shift;
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
shift;
|
|
|
|
;;
|
|
|
|
esac
|
2020-10-31 16:31:28 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
# we need an output list
|
|
|
|
if [ -z "$OUTPUT_FILE" ]
|
|
|
|
then
|
2020-11-01 13:32:34 -06:00
|
|
|
echo 'error: please give output file with "-o filename" format' >&2
|
|
|
|
exit 1
|
2020-10-31 16:31:28 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
# read input list if given
|
|
|
|
if [ ! -z "$INPUT_FILE" ] && [ -f "$INPUT_FILE" ]
|
|
|
|
then
|
2020-11-01 13:32:34 -06:00
|
|
|
cat "$INPUT_FILE" > 'tmp.txt'
|
2020-10-31 16:31:28 -05:00
|
|
|
fi
|
2020-11-01 07:17:20 -06:00
|
|
|
|
|
|
|
# load csv if csv file given
|
|
|
|
if [ ! -z "$CSV_FILE" ] && [ -f "$CSV_FILE" ]
|
|
|
|
then
|
2020-11-01 13:32:34 -06:00
|
|
|
# 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"
|
2020-11-01 07:17:20 -06:00
|
|
|
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
|
2020-11-01 13:32:34 -06:00
|
|
|
# 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"
|
2020-11-01 08:20:51 -06:00
|
|
|
fi
|
|
|
|
|
2020-10-31 16:31:28 -05:00
|
|
|
# thanks for service tmp.txt, but we dont need you anymore
|
|
|
|
rm 'tmp.txt'
|
2020-11-01 13:32:34 -06:00
|
|
|
|
|
|
|
# vim:set shiftwidth=4 softtabstop=4 expandtab:
|