TranslateProject/scripts/status/status.sh

27 lines
772 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/../.." # 进入TP root
function file-translating-p ()
{
local file="$*"
head -n 3 "$file" | grep -iE "^[^[].*translat|^\[#\]: translator: \([^[:space:]]+\)|fanyi|翻译" >/dev/null 2>&1
}
function get_status_of()
{
local file="$*"
git log --date=short --pretty=format:"{\"file\":\"${file}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "${file}"
}
while read -r file;do
if file-translating-p "${file}";then
translating="${translating} $(get_status_of "${file}")"
else
unselected="${unselected} $(get_status_of "${file}")"
fi
done< <(find sources -name "2*.md")
2018-11-23 22:12:56 +08:00
(
echo "${translating}"|jq -s "."
echo "${unselected}"|jq -s "."
2018-11-23 22:12:56 +08:00
)|jq -s '{"translating":.[0],"unselected":.[1]}'