|
1 | | -# Copyright (c) 2024, NVIDIA CORPORATION. |
| 1 | +# Copyright (c) 2024-2025, NVIDIA CORPORATION. |
2 | 2 | # |
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | # you may not use this file except in compliance with the License. |
|
43 | 43 | echo "Excluded file patterns: ${EXCLUDE_PATTERNS[@]}" |
44 | 44 |
|
45 | 45 | # Get changed files |
46 | | - FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) || (echo "Your base commit ID is too old, please try upmerge first." && exit 1) |
47 | | - RENAME_FILES=$(git diff --name-status ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^R" | grep -v "R100" | awk '{print $3}' || echo "") |
| 46 | + BASE_REF=$(git --no-pager log --oneline -1 | awk '{ print $NF }') |
| 47 | + echo "Base REF: ${BASE_REF}" |
| 48 | + FILES=$(git diff --name-only --diff-filter=AM ${BASE_REF} HEAD) || (echo "Your base commit ID is too old, please try upmerge first." && exit 1) |
| 49 | + RENAME_FILES=$(git diff --name-status ${BASE_REF} HEAD | grep "^R" | grep -v "R100" | awk '{print $3}' || echo "") |
48 | 50 | echo "${RENAME_FILES[@]}" |
49 | 51 | FILES=($FILES $RENAME_FILES) |
50 | 52 | echo "Files to be detected: ${FILES[@]}" |
@@ -76,10 +78,16 @@ runs: |
76 | 78 |
|
77 | 79 | # Output result |
78 | 80 | echo "--------- RESULT ---------" |
| 81 | + ERROR_MESSAGE="If the feature branch is not based on the latest target branch, \ |
| 82 | + git diff may include unexpected files marked as modified in the check that are not from the feature branch. \ |
| 83 | + This is because it tries to find a common commit between the two branches \ |
| 84 | + and can get confused if it is too old and there are lots of changes. \ |
| 85 | + If this happens please UPMERGE your PR to the latest development branch." |
79 | 86 | if [ ! -z "$NO_LICENSE_FILES" ]; then |
80 | 87 | echo "Following files missed copyright/license header or expired:" |
81 | 88 | echo $NO_LICENSE_FILES | tr ' ' '\n' |
82 | | - echo "If there are files that are not modified by your PR, please try upmerge first." |
| 89 | + echo "--------- NOTICE ---------" |
| 90 | + echo "${ERROR_MESSAGE}" |
83 | 91 | exit 1 |
84 | 92 | else |
85 | 93 | echo "All files passed the check" |
|
0 commit comments