Skip to content

Instantly share code, notes, and snippets.

@nickw108
Last active August 29, 2015 14:06
Show Gist options
  • Save nickw108/5947ec09ada89a2c90cf to your computer and use it in GitHub Desktop.
Save nickw108/5947ec09ada89a2c90cf to your computer and use it in GitHub Desktop.
<?php
$website = 'domain.com';
$path = '/path/to/htdocs';
$email = '[email protected]';
$git_status = shell_exec('git --git-dir=' . $path . '/.git --work-tree=' . $path . ' status');
$git_log = file_exists($path . '/.git-monitoring.log') ? file_get_contents($path . '/.git-monitoring.log') : '';
if (!preg_match('/working directory clean/ism', $git_status) && $git_log != $git_status) {
file_put_contents($path . '/.git-monitoring.log', $git_status);
$git_status = shell_exec('git --git-dir=' . $path . '/.git --work-tree=' . $path . ' status');
file_put_contents($path . '/.git-monitoring.log', $git_status);
$mail = 'Git status changed for ' . $website . '. Here is output:' . "\n\n" . $git_status;
mail($email, 'Git status changed for ' . $website . '.', $mail);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment