-
Notifications
You must be signed in to change notification settings - Fork 462
Expand file tree
/
Copy pathadd-license-hook.ps1
More file actions
28 lines (24 loc) · 866 Bytes
/
add-license-hook.ps1
File metadata and controls
28 lines (24 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
param(
[string[]]$Files
)
Write-Host "Running addlicense hook..."
# If pre-commit passed no files (e.g. manual run), fallback to full scan
if (-not $Files -or $Files.Count -eq 0) {
Write-Host "No files passed. scanning full tree..."
$Files = Get-ChildItem -Path src -Recurse -Include *.cs, *.java, *.xml |
Where-Object { $_.FullName -notmatch '\\obj\\|\\bin\\|Resources|bouncycastle|keepassdroid|TwofishCipher|SamsungPass' } |
Select-Object -ExpandProperty FullName
}
foreach ($f in $Files) {
# Skip known directories
if ($f -match '\\obj\\|\\bin\\') {
continue
}
# Handle XML separately
if ($f.ToLower().EndsWith('.xml')) {
addlicense -f GPLv3.txt --skip=1 $f
}
elseif ($f.ToLower().EndsWith('.cs') -or $f.ToLower().EndsWith('.java')) {
addlicense -f GPLv3.txt $f
}
}