मैं अपने आप को इस की तलाश में गया है, और मैंने पाया निम्नलिखित:
Git Powershell पूर्व प्रतिबद्ध हुक (Source)
## Editor's note: Link is dead as of 2014-5-2. If you have a copy, please add it.
पीएचपी सिंटेक्स जांच Git के लिए में पूर्व के लिए प्रतिबद्ध PowerShell (Soure)
##############################################################################
#
# PHP Syntax Check for Git pre-commit hook for Windows PowerShell
#
# Author: Vojtech Kusy <[email protected]>
#
###############################################################################
### INSTRUCTIONS ###
# Place the code to file "pre-commit" (no extension) and add it to the one of
# the following locations:
# 1) Repository hooks folder - C:\Path\To\Repository\.git\hooks
# 2) User profile template - C:\Users\<USER>\.git\templates\hooks
# 3) Global shared templates - C:\Program Files (x86)\Git\share\git-core\templates\hooks
#
# The hooks from user profile or from shared templates are copied from there
# each time you create or clone new repository.
### SETTINGS ###
# Path to the php.exe
$php_exe = "C:\Program Files (x86)\Zend\ZendServer\bin\php.exe";
# Extensions of the PHP files
$php_ext = "php|engine|theme|install|inc|module|test"
# Flag, if set to 1 git will unstage all files with errors, se to 0 to disable
$unstage_on_error = 0;
### FUNCTIONS ###
function php_syntax_check {
param([string]$php_bin, [string]$extensions, [int]$reset)
$err_counter = 0;
write-host "Pre-commit PHP syntax check:" -foregroundcolor "white"
git diff-index --name-only --cached HEAD -- | foreach {
if ($_ -match ".*\.($extensions)$") {
$file = $matches[0];
$errors = & $php_bin -l $file
if ($errors -match "No syntax errors detected in $file") {
write-host $file ": OK" -foregroundcolor "green"
}
else {
write-host $file ":" $errors -foregroundcolor "red"
if ($reset) {
git reset -q HEAD $file
write-host "Unstaging" $file "..." -foregroundcolor "magenta"
}
$err_counter++
}
}
}
if ($err_counter -gt 0) {
exit 1
}
}
### MAIN ###
php_syntax_check $php_exe $php_ext $unstage_on_error
कोड पूर्व-प्रतिबद्ध हुक के लिए है, लेकिन आप इसे बहुत कुछ करने के लिए संशोधित कर सकते हैं। आपको क्या करने की ज़रूरत है मदद करनी चाहिए!
नहीं यह स्क्रिप्ट (उस बात के लिए या किसी अन्य स्क्रिप्ट, अपने विस्तार की परवाह किए बिना) powershell स्क्रिप्ट आह्वान बनाने के लिए संभव है? – holygeek
क्या आप गिट हुक के बारे में कुछ और जानकारी दे सकते हैं। – JPBlanc
@ जेपीब्लैंक: ['गिटूक' मैनपेज।] (Http://www.kernel.org/pub/software/scm/git/docs/githooks.html) मुझे नहीं पता कि विंडोज के लिए अलग-अलग दस्तावेज उपलब्ध हैं या नहीं संस्करण (रों)। – intuited