Last active
August 29, 2015 14:17
-
-
Save dprevite/5a5aabb9b7708b0a9548 to your computer and use it in GitHub Desktop.
Search computer for all git repos and add lolcommits hook to all the post-commit files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$contents = '#!/bin/sh' . PHP_EOL . './Users/dprevite/Dropbox/lolcommits/post-commit' . PHP_EOL; | |
// Find all the existing post commit files | |
$gitPostCommitFiles = `locate post-commit`; | |
$gitPostCommitFiles = explode(PHP_EOL, trim($gitPostCommitFiles)); | |
// Loop through each match | |
foreach ($gitPostCommitFiles as $file) { | |
if (!file_exists(dirname($file) . '/post-commit')) { | |
echo 'No post commit file, creating' . PHP_EOL; | |
touch(dirname($file) . '/post-commit'); | |
chmod(dirname($file) . '/post-commit', 0777); | |
} | |
echo 'Putting hooks into ' . dirname($file) . '/post-commit' . PHP_EOL; | |
file_put_contents(dirname($file) . '/post-commit', $contents); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment