gitea-docusaurus/check_outdated.sh
John Olheiser 53e27a0e86
All checks were successful
Build and Publish Docs site / build-docs (push) Successful in 6m25s
Clone once (#52)
Closes #30
Closes #31
Closes #42

Rather than partially cloning, instead we clone once and then `clean` (to remove generated files), `reset` (to reset changed files), and `checkout` branches as needed. This should allow the outdated translation check to continue to work while also reducing build times significantly.

Before:
![before](/attachments/07c16ef5-110c-451a-9f1b-79f2c8b72caf)

After:
![after](/attachments/d6251f63-087d-4270-946f-63148b8f642a)

Reviewed-on: #52
Co-authored-by: John Olheiser <john+gitea@jolheiser.com>
Co-committed-by: John Olheiser <john+gitea@jolheiser.com>
2023-07-28 05:52:35 +00:00

38 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# This script takes `locale` as a param and checks if a specific locale version of document is up to date with English version
# 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
SED_INPLACE() {
if sed --version 2>/dev/null | grep -q GNU; then
sed -i "$@"
else
sed -i '' "$@"
fi
}
locale="$1"
cur_path=`pwd`
cd .tmp/upstream-docs
for file in `find ./docs/content -name "*.${locale}.md"`; do
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)"
SED_INPLACE '1s/---/---\nisOutdated: true/' $file
fi
done
cd "$cur_path"