Skip to content

Commit c8ee48e

Browse files
committed
hooks install ps1 loop
1 parent 91a148b commit c8ee48e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

git-hooks-install.ps1

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
# git-hooks-install.ps1
22
# by wilsonmar at gmail.com
3-
# After the repo is cloned, this PowerShell script copies
4-
# scripts in the repo's hooks folder into the .git/hooks
3+
# After the repo is cloned, this PowerShell multi-platform script
4+
# copies scripts in the repo's hooks folder into the .git/hooks
55
# and sets permissions.
66

7-
echo "Remove *.sample files in .git/hooks ..."
7+
#echo "Remove *.sample files in .git/hooks ..."
88
Remove-Item .git/hooks/*.sample
99

10-
echo "Copy hooks/git-commit into .git/hooks ..."
11-
10+
#echo "Copy hooks/git-commit into .git/hooks ..."
1211
Copy-Item hooks/* .git/hooks
1312
#Copy-Item hooks/git-commit .git/hooks
1413
#Copy-Item hooks/git-push .git/hooks
1514
#Copy-Item hooks/git-rebase .git/hooks
1615
#Copy-Item hooks/prepare-commit-msg .git/hooks
1716

18-
if( $IsWindows -eq $True ) {
19-
# icacls
20-
}
21-
if ( $IsOSX -eq $True){
22-
chmod +x .git/hooks/git-commit
23-
chmod +x .git/hooks/git-push
24-
chmod +x .git/hooks/git-rebase
25-
chmod +x .git/hooks/prepare-commit-msg
17+
#echo "Change permissions ..."
18+
$SUBDIR=".git/hooks"
19+
Get-ChildItem "$SUBDIR" -Filter *.log |
20+
Foreach-Object {
21+
$content = Get-Content $_.FullName
22+
echo $content
23+
if( $IsWindows -eq $True ) {
24+
# attrib to set file permissions
25+
# icacls to set ownership in Access Control Lists
26+
}
27+
if ( $IsOSX -eq $True){
28+
chmod +x $SUBDIR$content
29+
}
2630
}
2731

32+
#echo "Change permissions ..."
2833
ls .git/hooks
2934

30-
# echo "Done with status $? (0=OK)."
35+
echo "Done with status $? (0=OK)."

0 commit comments

Comments
 (0)