Translator credits: Space after comma and tabs-to-spaces

Change-Id: I412b035cf25f7ec40164d0d187881177c7de0f4e
Signed-off-by: Muhammet Kara <muhammet.kara@collabora.com>
pull/492/head
Muhammet Kara 2020-11-01 22:32:34 +03:00 committed by Muhammet Kara
parent 8e53541734
commit 0b9648445c
1 changed files with 57 additions and 55 deletions

View File

@ -23,92 +23,92 @@ OUTPUT_FILE=""
set -ef
print_help(){
usage='
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
--csv file give input from csv file
'
--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
'
echo "$usage"
echo "$usage"
}
find_hashs(){
# 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
# 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
}
collect_authors(){
for hash in $(find_hashs)
do
info=$(git show "$hash" --pretty=format:'%an' | head -n 1)
echo $info
done
for hash in $(find_hashs)
do
info=$(git show "$hash" --pretty=format:'%an' | head -n 1)
echo $info
done
}
# show help if no argument passed
if [ $# -lt 1 ]
then
print_help
exit 1
print_help
exit 1
fi
# parsing arguments
while [ $# -gt 1 ];
do
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
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
done
# we need an output list
if [ -z "$OUTPUT_FILE" ]
then
echo 'error: please give output file with "-o filename" format' >&2
exit 1
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'
cat "$INPUT_FILE" > 'tmp.txt'
fi
# 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"
# 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
@ -120,11 +120,13 @@ cat 'tmp.txt' | sort | uniq > "$OUTPUT_FILE"
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"
# 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
# thanks for service tmp.txt, but we dont need you anymore
rm 'tmp.txt'
# vim:set shiftwidth=4 softtabstop=4 expandtab: