From 71f0a9fc41e27f47e1c08a6ecdbd8bdb3a3aa65c Mon Sep 17 00:00:00 2001 From: Qiming Teng Date: Mon, 5 Oct 2020 17:08:55 +0800 Subject: [PATCH] Add a util script for localization team This PR adds a utility script for localization team to check changes made to the English (upstream) source since last time the localized version is updated (synchronized). --- scripts/lsync.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/lsync.sh diff --git a/scripts/lsync.sh b/scripts/lsync.sh new file mode 100755 index 0000000000..740b390be1 --- /dev/null +++ b/scripts/lsync.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# This script checks if the English version of a page has changed since a localized +# page has been committed. + +if [ "$#" -ne 1 ] || ! [ -f "$1" ]; then + echo -e "\nThis script checks if the English version of a page has changed since a " + echo -e "localized page has been committed.\n" + echo -e "Usage:\n\t$0 \n" >&2 + echo -e "Example:\n\t$0 content/zh/docs/concepts/_index.md\n" >&2 + exit 1 +fi + +LOCALIZED="$1" + +# Try get the English version +EN_VERSION=`echo $LOCALIZED | sed "s/content\/..\//content\/en\//g"` +if ! [ -f $EN_VERSION ]; then + echo "$EN_VERSION has been removed." + exit 2 +fi + +# Last commit for the localized file +LASTCOMMIT=`git log -n 1 --pretty=format:%h -- $LOCALIZED` + +git diff $LASTCOMMIT...HEAD $EN_VERSION + +if [ "$?" -eq 0 ]; then + echo "$LOCALIZED is still in sync" + exit 3 +fi