Skip to content

Commit

Permalink
CCM-8881: Fix up sync script to track changes to merged files and pri…
Browse files Browse the repository at this point in the history
…nt report.
  • Loading branch information
m-houston committed Mar 6, 2025
1 parent 67aca36 commit b5477b3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions scripts/githooks/sync-template-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ FILES_ADDED=()
FILES_WITH_CHANGES=()

# Loop through all files in the template directory
while IFS= read -r -d '' file; do
while IFS= read -r -d '' file || [[ -n $file ]]; do
relative_path="${file#./}" # Remove leading './'

# Check if the file is ignored
Expand All @@ -110,9 +110,13 @@ while IFS= read -r -d '' file; do
if ! diff -q "$file" "$target_path" > /dev/null 2>&1; then
if is_merge "$relative_path"; then
echo "Merging changes from $relative_path"
echo node "$(dirname "$0")/merge.js" "$target_path" "$file"
node "${scriptdir}/merge.js" "$target_path" "$file" > "$target_path.merged"
mv "$target_path.merged" "$target_path"
cp "$target_path" "${target_path}.bak"
node "${scriptdir}/merge.js" "$target_path" "$file" > "${target_path}.merged"
if ! cmp -s "${target_path}.merged" "${target_path}.bak"; then
FILES_WITH_CHANGES+=("${relative_path}")
mv "${target_path}.merged" "$target_path"
fi
rm -f "${target_path}.merged" "${target_path}.bak"
else
echo "Copying changes from $relative_path"
cp "$file" "$target_path"
Expand All @@ -123,19 +127,19 @@ while IFS= read -r -d '' file; do
fi
done < <(find . -type f -print0)

echo "${#FILES_ADDED[@]}" files added, "${#FILES_WITH_CHANGES[@]}" files with changes detected.

echo ------------------------------------------
echo "${#FILES_ADDED[@]} files added, ${#FILES_WITH_CHANGES[@]} files with changes detected."

if [ "$changes_only" == false ]; then
if [[ "$changes_only" == false && ${#FILES_ADDED[@]} -gt 0 ]]; then
echo ------------------------------------------
echo "New files added:"
printf ' - %s\n' "${FILES_ADDED[@]}"
fi


if [ "$new_only" == false ]; then
if [[ "$new_only" == false && ${#FILES_WITH_CHANGES[@]} -gt 0 ]]; then
echo ------------------------------------------
echo "Changed files:"
printf ' - %s\n' "${FILES_WITH_CHANGES[@]}"
fi

echo ------------------------------------------

0 comments on commit b5477b3

Please sign in to comment.