Skip to content

Instantly share code, notes, and snippets.

@stephenyeargin
Created July 31, 2012 16:23
Show Gist options
  • Save stephenyeargin/3218234 to your computer and use it in GitHub Desktop.
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.
<?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