Created
July 31, 2012 16:23
-
-
Save stephenyeargin/3218234 to your computer and use it in GitHub Desktop.
Use terminal-notifier to post Subversion status information into OS X Mountain Lion's notification center.
This file contains 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 | |
/* | |
Requires: | |
terminal-notifier - A ruby gem that talks to notification center | |
launchd/cron - to schedule `php /path/to/SVNStatus.php` to run. | |
*/ | |
// Config | |
$binary = '/path/to/bin/terminal-notifier'; | |
$projects = array( | |
array('repo_path' => '/path/to/repo', 'browse_path' => 'http://svnbrowse.yourdomain.com/r%d') | |
); | |
foreach ($projects as $project): | |
$output = shell_exec('svn stat -u ' . $project['repo_path']); | |
$lines = explode("\n", $output); | |
if (count($lines) > 2): | |
// Figure out what the last revision was | |
$lastkey = array_pop(array_keys($lines)); | |
$last_revision = trim(str_replace('Status against revision:', '', $lines[$lastkey-1])); | |
$repo_path = sprintf('%s', $project['repo_path']); | |
$browse_path = sprintf($project['browse_path'], $last_revision); | |
$message = sprintf('Your local copy is out of date. Latest version: %d', $last_revision); | |
$cmd = sprintf('%s -message "%s" -title "%s" -group "%s" -open %s', $binary, $message, $repo_path, md5($repo_path), $browse_path); | |
print $cmd . PHP_EOL; | |
shell_exec($cmd); | |
endif; | |
endforeach; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment