2023-06-08 03:34:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2023-07-28 05:52:35 +00:00
|
|
|
# This script takes `locale` as a param and checks if a specific locale version of document is up to date with English version
|
2023-06-08 03:34:23 +00:00
|
|
|
# If latest commit timestamp of English version is greater than the specific locale version,
|
|
|
|
|
# The specific locale version document will be marked as outdated
|
|
|
|
|
|
|
|
|
|
set -xe
|
|
|
|
|
|
2023-06-20 14:47:10 +00:00
|
|
|
SED_INPLACE() {
|
|
|
|
|
if sed --version 2>/dev/null | grep -q GNU; then
|
|
|
|
|
sed -i "$@"
|
|
|
|
|
else
|
|
|
|
|
sed -i '' "$@"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 05:52:35 +00:00
|
|
|
locale="$1"
|
2023-06-08 03:34:23 +00:00
|
|
|
cur_path=`pwd`
|
2023-07-28 05:52:35 +00:00
|
|
|
cd .tmp/upstream-docs
|
2023-06-08 03:34:23 +00:00
|
|
|
|
2023-07-27 14:55:46 +00:00
|
|
|
for file in `find ./docs/content -name "*.${locale}.md"`; do
|
2023-06-08 03:34:23 +00:00
|
|
|
file_en="${file/.${locale}/.en-us}"
|
|
|
|
|
if [ ! -f "$file_en" ]; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
latest_commit_time_en=$(git log -1 --format=%ct "$file_en")
|
|
|
|
|
latest_commit_time_locale=$(git log -1 --format=%ct "$file")
|
|
|
|
|
if [ -z "$latest_commit_time_locale" ]; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$latest_commit_time_en" -gt "$latest_commit_time_locale" ]]; then
|
|
|
|
|
echo "file: $file, lastest commit timestamp: $latest_commit_time_en (en ver), $latest_commit_time_locale ($locale ver)"
|
2023-06-20 14:47:10 +00:00
|
|
|
SED_INPLACE '1s/---/---\nisOutdated: true/' $file
|
2023-06-08 03:34:23 +00:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
cd "$cur_path"
|