Skip to content

Commit dc524da

Browse files
committed
chore: add commit hooks and CI check to block vendor DLLs and local config files
1 parent 7d0f9cd commit dc524da

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env pwsh
2+
# Prevent committing forbidden local files (PowerShell)
3+
$forbidden = '^\.mdt_dlls/|^mdt_devices\.json$|^mdt_probe\.json$'
4+
$staged = (& git diff --cached --name-only) -join "`n"
5+
$matches = @()
6+
foreach ($line in $staged -split "`n") {
7+
if ($line -match $forbidden) { $matches += $line }
8+
}
9+
if ($matches.Count -gt 0) {
10+
Write-Error "ERROR: Commit contains forbidden local files:"
11+
$matches | ForEach-Object { Write-Output " $_" }
12+
Write-Output "These files should remain local only. To remove them from the index run:`n git rm --cached <file>"
13+
exit 1
14+
}
15+
exit 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# Prevent committing forbidden local files
3+
forbidden='^\\.mdt_dlls/|^mdt_devices\\.json$|^mdt_probe\\.json$'
4+
staged=$(git diff --cached --name-only)
5+
echo "$staged" | grep -E "$forbidden" >/dev/null 2>&1
6+
if [ $? -eq 0 ]; then
7+
echo "ERROR: Commit contains forbidden local files:" >&2
8+
echo "$staged" | grep -E "$forbidden" >&2
9+
echo "These files should remain local only. To remove them from the index run:" >&2
10+
echo " git rm --cached <file>" >&2
11+
exit 1
12+
fi
13+
exit 0
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Block Forbidden Files
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
check-forbidden-files:
9+
name: Check for forbidden local files
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Fail if forbidden files are present
16+
run: |
17+
forbidden='(^\.mdt_dlls/|^mdt_devices\.json$|^mdt_probe\.json$)'
18+
matches=$(git ls-files | grep -E "$forbidden" || true)
19+
if [ -n "$matches" ]; then
20+
echo "ERROR: Repository contains forbidden local files:" >&2
21+
echo "$matches" >&2
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)