@@ -15,7 +15,7 @@ file_changed_in_pr() {
15
15
# Make sure file exists
16
16
[[ -f " $full_path " ]] || return 1
17
17
18
- # Check if the file is in a Git repo
18
+ # Check if the file is in a Git repo (it should be)
19
19
local repo_root
20
20
repo_root=$( git -C " $( dirname " $full_path " ) " rev-parse --show-toplevel 2> /dev/null)
21
21
if [[ -z " $repo_root " ]]; then
@@ -26,10 +26,14 @@ file_changed_in_pr() {
26
26
local rel_path
27
27
rel_path=$( realpath --relative-to=" $repo_root " " $full_path " )
28
28
29
- # Check if the file changed in the diff range
29
+ # Check if the file changed in the PR diff file that we have
30
30
(
31
31
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
33
37
) && return 0 || return 1
34
38
}
35
39
@@ -51,8 +55,9 @@ compare_and_copy() {
51
55
echo " File $source_file copied to $destination_file "
52
56
else
53
57
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" ;;
56
61
* ) echo " ⚠️ Unknown error" ;;
57
62
esac
58
63
fi
0 commit comments