Last active
December 16, 2015 22:39
-
-
Save Cerdic/5508086 to your computer and use it in GitHub Desktop.
Mon cherry-pick pour svn
This file contains hidden or 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 | |
// Report d'un commit d'un repertoire sur un autre | |
// le script fait le merge svn et prepare le log de comit dans log.txt | |
// mais ne fait pas le commit automatiquement car risque de conflits | |
// il faut le faire suivre de la commande comit manuelle si le diff est OK | |
// Syntaxe : | |
// cherry-pick.php -rNNNN source dest | |
// | |
// exemple d'utilisation : | |
// ./cherry-pick.php -r20468 branches/spip-3.0/ spip/ | |
// svn commit spip/ -F log.txt | |
$revision = $argv[1]; | |
$source = $argv[2]; | |
$dest = $argv[3]; | |
function exect($c,$echo=true){ | |
$output=""; | |
if ($echo) echo $c."\n"; | |
exec($c,$output); | |
if ($echo) echo implode("\n",$output)."\n"; | |
return $output; | |
} | |
// up | |
exect("svn up --ignore-externals $source $dest",false); | |
// log | |
$output = exect("svn log $revision $source"); | |
array_shift($output); | |
array_shift($output); | |
array_pop($output); | |
$log = trim(implode("\n",$output)); | |
exect("svn merge ".str_replace("-r","-c",$revision)." $source $dest"); | |
exect("svn status --ignore-externals $dest"); | |
$log = "Report de ".trim($revision,"-")." : ".$log; | |
file_put_contents("log.txt",$log); | |
exect("cat log.txt"); | |
$c = "svn commit $dest -F log.txt\n"; | |
#$c = "svn commit $dest -m\"Report de ".trim($revision,"-")." : ".addcslashes($log,'"')."\""; | |
echo $c."\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment