forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fece1f
commit d22d964
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Sort large PRs | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- master | ||
# TODO: make this work on synchronize, be smart about don't spam with | ||
# warning message each push | ||
types: [opened] | ||
paths: | ||
- 'data/**.json' | ||
- '**.cpp' | ||
- '**.h' | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
jobs: | ||
changed_files: | ||
runs-on: ubuntu-latest | ||
name: Post warning | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: calculate changes | ||
id: lines_changed | ||
run: | | ||
git remote add upstream https://github.com/CleverRaven/Cataclysm-DDA.git | ||
git fetch --depth=1 upstream master | ||
json_changed=$(git diff --numstat --ignore-blank-lines upstream/master -- 'data/**/*.json' | awk '{sum=$1+$2} END{print sum}') | ||
echo "Debug: lines of data/*.json added or deleted: $json_changed" | ||
cpp_changed=$(git diff --numstat --ignore-blank-lines upstream/master -- '**/*.cpp' '**/*.h' | awk '{sum=$1+$2} END{print sum}') | ||
echo "Debug: lines of *.cpp and *.h added or deleted: $cpp_changed" | ||
echo "json_changed=$json_changed" >> $GITHUB_OUTPUT | ||
echo "cpp_changed=$cpp_changed" >> $GITHUB_OUTPUT | ||
- if: ${{ steps.lines_changed.outputs.json_changed > 1000 || steps.lines_changed.outputs.cpp_changed > 300 }} | ||
run: | | ||
gh pr comment "$PR_NUMBER" --body "This is a large PR! Merging has been blocked until one of the project leads can take a look and approve it. This is a safety feature to prevent changes from being merged that would be immediately reverted." |