Last active
May 23, 2017 13:23
-
-
Save mlask/6954a8f5f8525193379ac51f2d930432 to your computer and use it in GitHub Desktop.
SVN repository quick sync script
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
#!/usr/bin/php | |
<?php | |
$status = shell_exec('svn status --non-interactive'); | |
if (strlen(trim($status)) > 0) | |
{ | |
$status = explode("\n", trim($status)); | |
echo("Syncing repository...\n"); | |
foreach ($status as $item) | |
{ | |
if (preg_match('/^\?\s+(.*)(?<!CVS\/Entries\.Log)$/', $item, $match)) | |
echo(shell_exec('svn add ' . svn_esc($match[1]))); | |
elseif (preg_match('/^\!\s+(.*)(?<!CVS\/Entries\.Log)$/', $item, $match)) | |
echo(shell_exec('svn rm ' . svn_esc($match[1]))); | |
elseif (preg_match('/^\!M\s+(.*)(?<!CVS\/Entries\.Log)$/', $item, $match)) | |
echo(shell_exec('svn rm --force ' . svn_esc($match[1]))); | |
elseif (preg_match('/^\?\s+(.*CVS\/Entries\.Log)$/', $item, $match)) | |
echo(shell_exec('rm ' . escapeshellarg($match[1]))); | |
} | |
} | |
else | |
echo("Nothing to sync.\n"); | |
function svn_esc ($name) | |
{ | |
if (strpos($name, '@') !== false) | |
$name .= '@'; | |
return escapeshellarg($name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment