8000 Add GHA testing whether files were added and deleted in the same PR. · matplotlib/matplotlib@f24b141 · GitHub
[go: up one dir, main page]

Skip to content

Commit f24b141

Browse files
committed
Add GHA testing whether files were added and deleted in the same PR.
1 parent 3d940e3 commit f24b141

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/clean_pr.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PR cleanliness
2+
on: [pull_request]
3+
4+
jobs:
5+
pr_clean:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Check added-and-deleted file
11+
run: |
12+
git fetch origin "$GITHUB_BASE_REF"
13+
base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')"
14+
ad="$(git log "$base..HEAD^2" --pretty=tformat: --name-status --diff-filter=AD |
15+
cut -f2 | sort | uniq --repeated)"
16+
if [[ -n "$ad" ]]; then
17+
printf 'The following files were both added and deleted in this PR:\n%s\n' "$ad"
18+
exit 1
19+
fi
20+

0 commit comments

Comments
 (0)
0