Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions scripts/lsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ fi

if [ -d "$1" ] ; then
SYNCED=1
for f in `find $1 -name "*.md"` ; do
EN_VERSION=`echo $f | sed "s/content\/.\{2,5\}\//content\/en\//g"`
if [ ! -e $EN_VERSION ]; then
while IFS= read -r -d '' f; do
EN_VERSION=$(echo "$f" | sed "s/content\/.\{2,5\}\//content\/en\//g")
if [ ! -e "$EN_VERSION" ]; then
echo -e "**removed**\t$EN_VERSION"
SYNCED=0
continue
fi

LASTCOMMIT=`git log -n 1 --pretty=format:%h -- $f`
git diff --exit-code --numstat $LASTCOMMIT...HEAD $EN_VERSION
if [ $? -ne 0 ] ; then
LASTCOMMIT=$(git log -n 1 --pretty=format:%h -- "$f")
if ! git diff --exit-code --numstat "$LASTCOMMIT...HEAD" -- "$EN_VERSION"; then
SYNCED=0
fi
done
done < <(find "$1" -name "*.md" -print0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would add -type f here.


if [ $SYNCED -eq 1 ]; then
echo "$1 is still in sync"
exit 0
Expand All @@ -43,18 +43,18 @@ fi
LOCALIZED="$1"

# Try get the English version
EN_VERSION=`echo $LOCALIZED | sed "s/content\/.\{2,5\}\//content\/en\//g"`
if [ ! -e $EN_VERSION ]; then
EN_VERSION=$(echo "$LOCALIZED" | sed "s/content\/.\{2,5\}\//content\/en\//g")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EN_VERSION=$(echo "$LOCALIZED" | sed "s/content\/.\{2,5\}\//content\/en\//g")
EN_VERSION="$(echo "$LOCALIZED" | sed "s/content\/.\{2,5\}\//content\/en\//g")"

if [ ! -e "$EN_VERSION" ]; then
echo "$EN_VERSION has been removed."
exit 3
fi

# Last commit for the localized path
LASTCOMMIT=`git log -n 1 --pretty=format:%h -- $LOCALIZED`
LASTCOMMIT=$(git log -n 1 --pretty=format:%h -- "$LOCALIZED")

git diff --exit-code $LASTCOMMIT...HEAD $EN_VERSION
diff_output=$(git diff --quiet "$LASTCOMMIT...HEAD" -- "$EN_VERSION" || echo "changed")

if [ "$?" -eq 0 ]; then
if [ -z "$diff_output" ]; then
echo "$LOCALIZED is still in sync"
exit 0
fi