From a1c33ddf89284ba43183bc5e9d0bc941cd7bd61a Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Fri, 15 Oct 2021 12:48:29 +0200 Subject: [PATCH] Backport PR #21359: Add GHA testing whether files were added and deleted in the same PR. --- .github/workflows/clean_pr.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/clean_pr.yml diff --git a/.github/workflows/clean_pr.yml b/.github/workflows/clean_pr.yml new file mode 100644 index 000000000000..fc2acc0b2e4c --- /dev/null +++ b/.github/workflows/clean_pr.yml @@ -0,0 +1,22 @@ +name: PR cleanliness +on: [pull_request] + +jobs: + pr_clean: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - name: Check for added-and-deleted files + run: | + git fetch --quiet origin "$GITHUB_BASE_REF" + base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')" + ad="$(git log "$base..HEAD^2" --pretty=tformat: --name-status --diff-filter=AD | + cut --fields 2 | sort | uniq --repeated)" + if [[ -n "$ad" ]]; then + printf 'The following files were both added and deleted in this PR:\n%s\n' "$ad" + exit 1 + fi +