|
19 | 19 |
|
20 | 20 | if [ -d "$1" ] ; then
|
21 | 21 | SYNCED=1
|
22 |
| - for f in `find $1 -name "*.md"` ; do |
23 |
| - EN_VERSION=`echo $f | sed "s/content\/.\{2,5\}\//content\/en\//g"` |
24 |
| - if [ ! -e $EN_VERSION ]; then |
| 22 | + while IFS= read -r -d '' f; do |
| 23 | + EN_VERSION=$(echo "$f" | sed "s/content\/.\{2,5\}\//content\/en\//g") |
| 24 | + if [ ! -e "$EN_VERSION" ]; then |
25 | 25 | echo -e "**removed**\t$EN_VERSION"
|
26 | 26 | SYNCED=0
|
27 | 27 | continue
|
28 | 28 | fi
|
29 | 29 |
|
30 |
| - LASTCOMMIT=`git log -n 1 --pretty=format:%h -- $f` |
31 |
| - git diff --exit-code --numstat $LASTCOMMIT...HEAD $EN_VERSION |
32 |
| - if [ $? -ne 0 ] ; then |
| 30 | + LASTCOMMIT=$(git log -n 1 --pretty=format:%h -- "$f") |
| 31 | + if ! git diff --exit-code --numstat "$LASTCOMMIT...HEAD" -- "$EN_VERSION"; then |
33 | 32 | SYNCED=0
|
34 | 33 | fi
|
35 |
| - done |
| 34 | + done < <(find "$1" -name "*.md" -print0) |
| 35 | + |
36 | 36 | if [ $SYNCED -eq 1 ]; then
|
37 | 37 | echo "$1 is still in sync"
|
38 | 38 | exit 0
|
|
43 | 43 | LOCALIZED="$1"
|
44 | 44 |
|
45 | 45 | # Try get the English version
|
46 |
| -EN_VERSION=`echo $LOCALIZED | sed "s/content\/.\{2,5\}\//content\/en\//g"` |
47 |
| -if [ ! -e $EN_VERSION ]; then |
| 46 | +EN_VERSION=$(echo "$LOCALIZED" | sed "s/content\/.\{2,5\}\//content\/en\//g") |
| 47 | +if [ ! -e "$EN_VERSION" ]; then |
48 | 48 | echo "$EN_VERSION has been removed."
|
49 | 49 | exit 3
|
50 | 50 | fi
|
51 | 51 |
|
52 | 52 | # Last commit for the localized path
|
53 |
| -LASTCOMMIT=`git log -n 1 --pretty=format:%h -- $LOCALIZED` |
| 53 | +LASTCOMMIT=$(git log -n 1 --pretty=format:%h -- "$LOCALIZED") |
54 | 54 |
|
55 |
| -git diff --exit-code $LASTCOMMIT...HEAD $EN_VERSION |
| 55 | +diff_output=$(git diff --quiet "$LASTCOMMIT...HEAD" -- "$EN_VERSION" || echo "changed") |
56 | 56 |
|
57 |
| -if [ "$?" -eq 0 ]; then |
| 57 | +if [ -z "$diff_output" ]; then |
58 | 58 | echo "$LOCALIZED is still in sync"
|
59 | 59 | exit 0
|
60 | 60 | fi
|
0 commit comments