|
2 | 2 |
|
3 | 3 | # Get inputs from command |
4 | 4 | owner_repository=$1 |
5 | | -pr_number=$2 |
| 5 | +base_ref=$2 |
6 | 6 |
|
7 | | -url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files" |
8 | | -echo $url |
| 7 | +#download the boards.txt file from the base branch |
| 8 | +curl -L -o boards_base.txt https://raw.githubusercontent.com/$owner_repository/$base_ref/boards.txt |
| 9 | + |
| 10 | +#url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files" |
| 11 | +#echo $url |
9 | 12 |
|
10 | 13 | # Get changes in boards.txt file from PR |
11 | | -Boards_modified_url=$(curl -s $url | jq -r '.[] | select(.filename == "boards.txt") | .raw_url') |
| 14 | +#Boards_modified_url=$(curl -s $url | jq -r '.[] | select(.filename == "boards.txt") | .raw_url') |
12 | 15 |
|
13 | 16 | # Echo the modified boards.txt file URL |
14 | | -echo "Modified boards.txt file URL:" |
15 | | -echo $Boards_modified_url |
| 17 | +#echo "Modified boards.txt file URL:" |
| 18 | +#echo $Boards_modified_url |
16 | 19 |
|
17 | 20 | # Download the modified boards.txt file |
18 | | -curl -L -o boards_pr.txt $Boards_modified_url |
19 | | - |
20 | | -# Check if the file is downloaded |
21 | | -if [ ! -f boards_pr.txt ] |
22 | | -then |
23 | | - echo "Error: boards.txt file not downloaded" |
24 | | - exit 1 |
25 | | -fi |
26 | | - |
27 | | -# cat both files |
28 | | -echo "boards.txt file in the repo:" |
29 | | -cat boards.txt |
30 | | -echo "Modified boards.txt file:" |
31 | | -cat boards_pr.txt |
32 | | - |
33 | | -# Use sed to replace CRLF with LF |
34 | | -sed -i 's/\r$//' boards.txt |
35 | | -sed -i 's/\r$//' boards_pr.txt |
| 21 | +#curl -L -o boards_pr.txt $Boards_modified_url |
36 | 22 |
|
37 | | -# Compare boards.txt file in the repo with the modified file |
38 | | -diff=$(diff -u boards.txt boards_pr.txt) |
| 23 | +# Compare boards.txt file in the repo with the modified file from PR |
| 24 | +diff=$(diff -u boards_base.txt boards.txt) |
39 | 25 |
|
40 | 26 | # Check if the diff is empty |
41 | 27 | if [ -z "$diff" ] |
|
0 commit comments