Files
Odoo-Modules/fusion_accounting/tools/check_odoo_diff.sh
2026-04-19 00:56:49 -04:00

84 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# check_odoo_diff.sh
#
# Diff a single Odoo Enterprise accounting module across two pinned snapshots
# and produce a categorized change report.
#
# Usage:
# tools/check_odoo_diff.sh <module> <from_version> <to_version> [<output_md>]
#
# Example:
# tools/check_odoo_diff.sh account_accountant v19 v20 reports/v20_accountant_diff.md
set -euo pipefail
MODULE="${1:?Usage: check_odoo_diff.sh <module> <from_version> <to_version> [<output_md>]}"
FROM="${2:?from_version required (e.g. v19)}"
TO="${3:?to_version required (e.g. v20)}"
OUT="${4:-/dev/stdout}"
ROOT="${REPACKAGED_ODOO_ROOT:-/Users/gurpreet/Github/RePackaged-Odoo}"
FROM_DIR="$ROOT/accounting-$FROM/$MODULE"
TO_DIR="$ROOT/accounting-$TO/$MODULE"
if [ ! -d "$FROM_DIR" ]; then
echo "ERROR: $FROM_DIR does not exist. Snapshot $FROM not yet present?" >&2
exit 1
fi
if [ ! -d "$TO_DIR" ]; then
echo "ERROR: $TO_DIR does not exist. Snapshot $TO not yet present?" >&2
exit 1
fi
classify() {
local f="$1"
case "$f" in
*/views/*|*/static/src/components/*|*/report/*|*/wizard/*_views.xml|*/wizards/*_views.xml)
echo "[MIRROR]" ;;
*/models/*_engine.py|*/services/*)
echo "[ABSTRACT]" ;;
*/__manifest__.py)
echo "[MANIFEST]" ;;
*/tests/*)
echo "[TEST]" ;;
*)
echo "[REVIEW]" ;;
esac
}
{
echo "# Diff Report: $MODULE ($FROM -> $TO)"
echo ""
echo "Generated: $(date '+%Y-%m-%d %H:%M:%S')"
echo ""
echo "## Changed Files (with classification suggestion)"
echo ""
diff -ruN --brief "$FROM_DIR" "$TO_DIR" | while read -r line; do
case "$line" in
"Files "*" and "*" differ")
file=$(echo "$line" | sed -E 's/^Files (.+) and .+ differ$/\1/' | sed "s|$FROM_DIR/||")
tag=$(classify "$file")
echo "- $tag \`$file\`"
;;
"Only in $TO_DIR"*)
file=$(echo "$line" | sed -E "s|Only in $TO_DIR(.*): (.+)|\1/\2|" | sed "s|^/||")
tag=$(classify "$file")
echo "- $tag NEW: \`$file\`"
;;
"Only in $FROM_DIR"*)
file=$(echo "$line" | sed -E "s|Only in $FROM_DIR(.*): (.+)|\1/\2|" | sed "s|^/||")
tag=$(classify "$file")
echo "- $tag REMOVED: \`$file\`"
;;
esac
done
echo ""
echo "## Full Diff (truncated to first 2000 lines)"
echo ""
echo '```diff'
diff -ruN "$FROM_DIR" "$TO_DIR" | head -2000
echo '```'
} > "$OUT"
echo "Diff report written to: $OUT" >&2