Guest User

Untitled

a guest
May 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. function getRepoName($repo) {
  4. return strtoupper(str_replace('/', '', str_replace('/svn/svn.localhost/', '', $repo)));
  5. }
  6.  
  7. require_once('phpmail/class.phpmailer.php');
  8.  
  9. $repository = isset($argv[1]) ? $argv[1] : '';
  10. $revision = isset($argv[2]) ? $argv[2] : '';
  11.  
  12. $author = strtoupper(exec('svnlook author ' . $repository));
  13. $changed = exec('svnlook changed ' . $repository);
  14. $comments = exec('svnlook log ' . $repository);
  15.  
  16. $diff = '';
  17. $fp = popen('svnlook diff ' . $repository, "r");
  18. while(!feof($fp)) {
  19. $diff .= fread($fp, 1024);
  20. flush();
  21. }
  22. pclose($fp);
  23.  
  24. $body = "
  25. Hi,\n\n
  26. $author has just committed
  27. revision $revision in " . getRepoName($repository) . "
  28. and said \n\n$comments.
  29. \n\n\n\n
  30. The following files have changed :\n\n$changed
  31. \n\n\n\nThe changelog is given below $diff";
  32.  
  33. $mail = new PHPMailer();
  34. $mail->From = 'svn@localhost';
  35. $mail->FromName = 'SVN Server';
  36. $mail->AddAddress('repo.admin@localhost', 'Repo Admin');
  37.  
  38. $mail->Subject = 'SVN Commit - ' . getRepoName($repository) . ' - Revision ' . $revision;
  39. $mail->Body = $body;
  40.  
  41. if(!$mail->Send()) {
  42. echo "Error sending: " . $mail->ErrorInfo;;
  43. }
  44.  
  45. ?>
Add Comment
Please, Sign In to add comment