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