Skip to content

Instantly share code, notes, and snippets.

@dprevite
Last active August 29, 2015 14:17
Show Gist options
  • Save dprevite/5a5aabb9b7708b0a9548 to your computer and use it in GitHub Desktop.
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
<?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