11# This workflow updates the list of deleted files based on the recent changes and creates a pull request.
2+ # It compares the current master with the data/deleted.files file and cleans the file from any re-introduced files.
23# It compares the current master with the stable branch and adds all deleted files to the data/deleted.files file
34# unless they are already listed there or are excluded from the release archives (export-ignore in .gitattributes).
5+ # Any additions are made to the top of the list with a single trailing line before the first "# removed in" line.
6+ # Finally, the list of newly removed entries receives a header "# removed in $(date -I)" with the current ISO date.
47
58name : " Update deleted files"
69on :
@@ -18,18 +21,34 @@ jobs:
1821 with :
1922 fetch-depth : 0
2023
21- - name : Update deleted files
24+ - name : Cleaning list from re-introduced files
25+ run : |
26+ for E in $(git ls-tree -r master --name-only); do
27+ if (git check-attr export-ignore "$E" | grep -q "export-ignore: set"); then
28+ continue
29+ fi
30+ grep -v "^$E$" data/deleted.files > data/deleted.files.tmp && mv data/deleted.files{.tmp,}
31+ done
32+
33+ - name : Update list with deleted files
2234 run : |
2335 for F in $(git diff origin/stable..HEAD --summary | awk '/^ delete/ && $4 !~ /^(VERSION)/ {print $4}'); do
2436 if (git check-attr export-ignore "$F" | grep -q "export-ignore: set"); then
2537 continue
2638 fi
27- if grep -q "^$F" data/deleted.files; then
39+ if grep -q "^$F$ " data/deleted.files; then
2840 continue
2941 fi
30- echo "$F" >> data/deleted.files
42+ if ( ! test -f "data/deleted.files.tmp"); then
43+ awk -v "input=# newly removed" '/# removed in/ && !found {print input; found=1} 1' data/deleted.files > data/deleted.files.tmp && cp data/deleted.files{.tmp,}
44+ fi
45+ awk -v "input=$F" '/# removed in/ && !found {print input; found=1} 1' data/deleted.files > data/deleted.files.tmp && cp data/deleted.files{.tmp,}
3146 done
32-
47+ if (test -f "data/deleted.files.tmp"); then
48+ awk '/# removed in/ && !found {printf("\n"); found=1} 1' data/deleted.files > data/deleted.files.tmp && mv data/deleted.files{.tmp,}
49+ sed -i "s/^# newly removed/# removed in $(date -I)/" data/deleted.files
50+ fi
51+
3352 - name : Create Pull Request
3453 uses : peter-evans/create-pull-request@v4
3554 with :
0 commit comments