@@ -102,14 +102,22 @@ jobs:
102
102
SOURCE=$(echo "$LINE" | awk '{print $1}')
103
103
DEST=$(echo "$LINE" | awk '{print $2}')
104
104
105
- # Check if there are actual content changes using git diff
106
- # --numstat gives us numeric stats: added lines, removed lines, filename
107
- # If the file was only renamed with no content changes, it will show 0 0
108
- GIT_DIFF=$(git diff --cached --numstat "$SOURCE" "$DEST")
109
- ADDED_LINES=$(echo "$GIT_DIFF" | awk '{print $1}')
110
- REMOVED_LINES=$(echo "$GIT_DIFF" | awk '{print $2}')
105
+ # Check if there are actual content changes using git diff with -M (detect renames)
106
+ # If there's output from the diff command beyond the rename header, there are content changes
107
+ DIFF_OUTPUT=$(git diff --cached -M -- "$SOURCE" "$DEST")
108
+ # Count lines that start with +/- (changes) but ignore the rename header lines
109
+ CHANGE_COUNT=$(echo "$DIFF_OUTPUT" | grep -v "^renamed:" | grep -v "^─" | grep -E "^\+|^-" | wc -l)
111
110
112
- echo "Git diff for $SOURCE → $DEST: $ADDED_LINES lines added, $REMOVED_LINES lines removed"
111
+ echo "Git diff for $SOURCE → $DEST: $CHANGE_COUNT lines changed"
112
+
113
+ # Determine if this is just a rename or if content was also changed
114
+ if [ "$CHANGE_COUNT" -eq 0 ]; then
115
+ CONTENT_UNCHANGED=true
116
+ echo "Pure rename detected (no content changes)"
117
+ else
118
+ CONTENT_UNCHANGED=false
119
+ echo "Content changes detected along with rename"
120
+ fi
113
121
114
122
# Replace 'en' with current locale in paths
115
123
SOURCE_LOCALE=${SOURCE/content\/en/content\/$LOCALE}
@@ -126,8 +134,7 @@ jobs:
126
134
127
135
# If the content is identical (just a rename, not a modification)
128
136
# then update the timestamps in the translation file
129
- # Git diff showing 0 added and 0 removed lines means identical content
130
- if [ "$ADDED_LINES" = "0" ] && [ "$REMOVED_LINES" = "0" ]; then
137
+ if [ "$CONTENT_UNCHANGED" = "true" ]; then
131
138
echo "Content unchanged, updating timestamps in $DEST_LOCALE"
132
139
133
140
# Update source-updated-at and translation-updated-at in the file
0 commit comments