@@ -15,7 +15,7 @@ file_changed_in_pr() {
1515 # Make sure file exists
1616 [[ -f " $full_path " ]] || return 1
1717
18- # Check if the file is in a Git repo
18+ # Check if the file is in a Git repo (it should be)
1919 local repo_root
2020 repo_root=$( git -C " $( dirname " $full_path " ) " rev-parse --show-toplevel 2> /dev/null)
2121 if [[ -z " $repo_root " ]]; then
@@ -26,10 +26,14 @@ file_changed_in_pr() {
2626 local rel_path
2727 rel_path=$( realpath --relative-to=" $repo_root " " $full_path " )
2828
29- # Check if the file changed in the diff range
29+ # Check if the file changed in the PR diff file that we have
3030 (
3131 cd " $repo_root " || return 2
32- git diff --name-only " $base_branch " ...HEAD | grep -q " ^$rel_path $"
32+ if [ -f " $PR_DIFF " ]; then # PR_DIFF should be set by the calling script
33+ grep -q " b/$rel_path " " $pr_diff " # Add b/ to match diff patterns
34+ else
35+ return 3
36+ fi
3337 ) && return 0 || return 1
3438}
3539
@@ -51,8 +55,9 @@ compare_and_copy() {
5155 echo " File $source_file copied to $destination_file "
5256 else
5357 case $? in
54- 1) echo " ❌ File has NOT changed" ;;
55- 2) echo " 🚫 Not in a Git repo" ;;
58+ 1) echo " ❌ File has NOT changed in PR" ;;
59+ 2) echo " 🚫 Not in Git repository" ;;
60+ 3) echo " 🚫 No PR diff file found" ;;
5661 * ) echo " ⚠️ Unknown error" ;;
5762 esac
5863 fi
0 commit comments