-
-
Notifications
You must be signed in to change notification settings - Fork 161
44 lines (36 loc) · 1.15 KB
/
check-reference.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Check patch references
on:
push:
branches-ignore:
- dependabot/**
schedule:
# Once every day at midnight UTC
- cron: "0 0 * * *"
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout patches
uses: actions/checkout@v4
- name: Checkout core
uses: actions/checkout@v4
with:
repository: 'homebrew/homebrew-core'
path: homebrew-core
- name: Configure Git user
uses: Homebrew/actions/git-user-config@master
with:
username: BrewTestBot
- name: Detect references
run: |
core_patches=$(git -C homebrew-core grep -h "Homebrew/formula-patches" | awk -F/ '{print $(NF-1)"/"$NF}' | tr -d '"')
all_patches=$(git ls-files -- '*/*' ':^.*/*')
git checkout -b remove-unused-patches
for patch in $all_patches; do
if ! grep -qx "$core_patches" <<< "$patch"; then
echo "Unused patch: $patch; deleting."
git rm "$patch"
git commit -m "${patch%%/*}: remove unused ${patch#*/}"
fi
done
git push origin remove-unused-patches