Skip to content

Commit

Permalink
Add GitHub action to check for changes to subtrees
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Jan 24, 2021
1 parent d2b4939 commit db0baba
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/scripts/check-modified-subtree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset

# This script will print GitHub errors when files from subtrees have been edited.
# Those files should be edited in their respective repositories.

MASTER_REVISION=$(git rev-list --first-parent origin/master | head -n 1)
DIFFED_FILES=$(git diff --name-only "$MASTER_REVISION")

FAILED=false

if echo "$DIFFED_FILES" | grep -qP "^gamemode/modules/fpp/pp/"; then
echo "::error::Files from Falco's Prop Protection have been edited. Please submit a PR to https://github.com/fptje/falcos-Prop-protection instead!"
FAILED=true
fi

if echo "$DIFFED_FILES" | grep -qP "^gamemode/libraries/fn.lua"; then
echo "::error::The fn library has been edited. Please submit a PR to https://github.com/fptje/GModFunctional instead!"
FAILED=true
fi

if echo "$DIFFED_FILES" | grep -qP "^gamemode/libraries/mysqlite/mysqlite.lua"; then
echo "::error::The MySQLite library has been edited. Please submit a PR to https://github.com/fptje/MySQLite instead!"
FAILED=true
fi

if echo "$DIFFED_FILES" | grep -qP "^gamemode/libraries/simplerr.lua"; then
echo "::error::The Simplerr library has been edited. Please submit a PR to https://github.com/fptje/simplerr instead!"
FAILED=true
fi

if echo "$DIFFED_FILES" | grep -qP "^gamemode/libraries/sh_cami.lua"; then
echo "::error::The CAMI library has been edited. Please submit a PR to https://github.com/glua/CAMI instead!"
FAILED=true
fi

if echo "$DIFFED_FILES" | grep -qP "^gamemode/modules/fspectate/"; then
echo "::error::Files from FSpectate have been edited. Please submit a PR to https://github.com/fptje/FSpectate instead!"
FAILED=true
fi

if [[ "$FAILED" = true ]]; then
exit 1
fi
15 changes: 15 additions & 0 deletions .github/workflows/check-modified-subtree.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: check-modified-subtree
on:
pull_request:
branches:
- master
jobs:
check-modified-subtree:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
# Make sure there is access to the master branch
fetch-depth: 0
clean: false
- run: ./.github/scripts/check-modified-subtree.sh

2 comments on commit db0baba

@Barti171
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pokrenite

@FPtje
Copy link
Owner Author

@FPtje FPtje commented on db0baba Feb 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you stop adding random comments to commits? @Barti171

Please sign in to comment.