Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CI to detect references #905

Closed
wants to merge 16 commits into from
Closed
44 changes: 44 additions & 0 deletions .github/workflows/check-reference.yml
@@ -0,0 +1,44 @@
name: Check patch references

on:
push:
branches-ignore:
- dependabot/**
schedule:
# Once every day at midnight UTC
- cron: "0 0 * * *"

jobs:
stale:
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
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
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved
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 -- '*/*' ':^.*/*')
SMillerDev marked this conversation as resolved.
Show resolved Hide resolved

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