From 432a8b049e98f48b4de0bb27d7a32623b8392e59 Mon Sep 17 00:00:00 2001 From: Bryce Meyer Date: Fri, 23 May 2025 12:46:46 +0200 Subject: [PATCH 1/3] modified update script to handle renamed files properly --- update.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/update.sh b/update.sh index 52e92c3a..68aaf84c 100755 --- a/update.sh +++ b/update.sh @@ -22,6 +22,7 @@ CHANGED=$(git diff --name-status "$LAST_TAG" HEAD) # 2. Prepare lists ADDED_MODIFIED=() DELETED=() +RENAMED=() while IFS= read -r line; do STATUS=$(echo "$line" | awk '{print $1}') @@ -33,10 +34,39 @@ while IFS= read -r line; do ADDED_MODIFIED+=("$FILE") elif [[ "$STATUS" == "D" ]]; then DELETED+=("$FILE") + elif [[ "$STATUS" == "R" ]]; then + OLD_FILE=$(echo "$line" | awk '{print $2}') + NEW_FILE=$(echo "$line" | awk '{print $3}') + RENAMED+=("$OLD_FILE|$NEW_FILE") fi done <<< "$CHANGED" -# 3. Copy new/modified files +# 3. Handle renamed files first +for RENAME in "${RENAMED[@]}"; do + OLD_FILE=$(echo "$RENAME" | cut -d'|' -f1) + NEW_FILE=$(echo "$RENAME" | cut -d'|' -f2) + + if [[ "$OLD_FILE" == app/Providers/* || "$OLD_FILE" == UPGRADE*.md || "$OLD_FILE" == "update.sh" ]]; then + continue + fi + + OLD_PATH="$CHILD_PATH/$OLD_FILE" + NEW_PATH="$CHILD_PATH/$NEW_FILE" + + # If the old file exists in child repo, move it to the new location + if [ -f "$OLD_PATH" ]; then + mkdir -p "$(dirname "$NEW_PATH")" + mv "$OLD_PATH" "$NEW_PATH" + echo "Renamed $OLD_FILE to $NEW_FILE in child repository" + else + # If old file doesn't exist, just copy the new file + mkdir -p "$(dirname "$NEW_PATH")" + cp "$NEW_FILE" "$NEW_PATH" + echo "Copied $NEW_FILE to child repository (rename from $OLD_FILE)" + fi +done + +# 4. Copy new/modified files SAFE_FILES=() for FILE in "${ADDED_MODIFIED[@]}"; do if [[ "$FILE" == app/Providers/* || "$FILE" == UPGRADE*.md || "$FILE" == "update.sh" ]]; then @@ -52,7 +82,7 @@ for FILE in "${ADDED_MODIFIED[@]}"; do echo "Copied $FILE to $DEST" done -# 4. Delete removed files +# 5. Delete removed files for FILE in "${DELETED[@]}"; do if [[ "$FILE" == app/Providers/* || "$FILE" == UPGRADE*.md || "$FILE" == "update.sh" ]]; then continue @@ -64,13 +94,14 @@ for FILE in "${DELETED[@]}"; do fi done -# 5. Compare diffs and report +# 6. Compare diffs and report # Get the latest tag for the 'to' version TO_TAG=$(git describe --tags --abbrev=0) REPORT_NAME="update_report_${LAST_TAG}_to_${TO_TAG}.txt" REPORT="$CHILD_PATH/$REPORT_NAME" > "$REPORT" +# Compare added/modified files for FILE in "${ADDED_MODIFIED[@]}"; do if [[ "$FILE" == app/Providers/* || "$FILE" == UPGRADE*.md || "$FILE" == "update.sh" ]]; then continue @@ -88,6 +119,28 @@ for FILE in "${ADDED_MODIFIED[@]}"; do rm -f /tmp/main_diff /tmp/child_diff done +# Compare renamed files +for RENAME in "${RENAMED[@]}"; do + OLD_FILE=$(echo "$RENAME" | cut -d'|' -f1) + NEW_FILE=$(echo "$RENAME" | cut -d'|' -f2) + + if [[ "$OLD_FILE" == app/Providers/* || "$OLD_FILE" == UPGRADE*.md || "$OLD_FILE" == "update.sh" ]]; then + continue + fi + + # Generate unified diff in main repo for the rename + git diff "$LAST_TAG" -- "$NEW_FILE" | grep -v '^index' | sed 's/[[:space:]]*$//' > /tmp/main_diff + # Generate unified diff in child repo for the new file + pushd "$CHILD_PATH" > /dev/null + git diff -- "$NEW_FILE" | grep -v '^index' | sed 's/[[:space:]]*$//' > /tmp/child_diff + popd > /dev/null + # Compare the diffs byte-for-byte + if ! diff -q /tmp/main_diff /tmp/child_diff > /dev/null; then + echo "$NEW_FILE (renamed from $OLD_FILE)" >> "$REPORT" + fi + rm -f /tmp/main_diff /tmp/child_diff +done + # Compare deleted files for FILE in "${DELETED[@]}"; do if [[ "$FILE" == app/Providers/* || "$FILE" == UPGRADE*.md || "$FILE" == "update.sh" ]]; then From 9f6ce47ea538d802b7c8f5112c18c86db95c8cb1 Mon Sep 17 00:00:00 2001 From: Bryce Meyer Date: Fri, 23 May 2025 12:49:50 +0200 Subject: [PATCH 2/3] renamed job --- .../{Statistics => Statistic}/ProcessTargetStatisticsJob.php | 2 +- .../Jobs/{Statistics => Statistic}/RecountStatisticJob.php | 2 +- .../ProcessTargetStatisticsJobTest.php | 2 +- .../Jobs/{Statistics => Statistic}/RecountStatisticJobTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename code/app/Athenia/Jobs/{Statistics => Statistic}/ProcessTargetStatisticsJob.php (96%) rename code/app/Athenia/Jobs/{Statistics => Statistic}/RecountStatisticJob.php (96%) rename code/tests/Athenia/Unit/Jobs/{Statistics => Statistic}/ProcessTargetStatisticsJobTest.php (98%) rename code/tests/Athenia/Unit/Jobs/{Statistics => Statistic}/RecountStatisticJobTest.php (98%) diff --git a/code/app/Athenia/Jobs/Statistics/ProcessTargetStatisticsJob.php b/code/app/Athenia/Jobs/Statistic/ProcessTargetStatisticsJob.php similarity index 96% rename from code/app/Athenia/Jobs/Statistics/ProcessTargetStatisticsJob.php rename to code/app/Athenia/Jobs/Statistic/ProcessTargetStatisticsJob.php index 1b814dc7..c1dab974 100644 --- a/code/app/Athenia/Jobs/Statistics/ProcessTargetStatisticsJob.php +++ b/code/app/Athenia/Jobs/Statistic/ProcessTargetStatisticsJob.php @@ -1,7 +1,7 @@ Date: Fri, 23 May 2025 12:51:26 +0200 Subject: [PATCH 3/3] renamed stats --- .../factories/{Statistics => Statistic}/StatisticFactory.php | 2 +- .../{Statistics => Statistic}/StatisticFilterFactory.php | 2 +- .../{Statistics => Statistic}/TargetStatisticFactory.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename code/database/factories/{Statistics => Statistic}/StatisticFactory.php (94%) rename code/database/factories/{Statistics => Statistic}/StatisticFilterFactory.php (95%) rename code/database/factories/{Statistics => Statistic}/TargetStatisticFactory.php (97%) diff --git a/code/database/factories/Statistics/StatisticFactory.php b/code/database/factories/Statistic/StatisticFactory.php similarity index 94% rename from code/database/factories/Statistics/StatisticFactory.php rename to code/database/factories/Statistic/StatisticFactory.php index 5455aebb..dbbf8b4c 100644 --- a/code/database/factories/Statistics/StatisticFactory.php +++ b/code/database/factories/Statistic/StatisticFactory.php @@ -1,7 +1,7 @@