Exemplo n.º 1
0
 public function GetLog()
 {
     global $scm_url, $scm_getpaths, $scm_limit;
     // Set flags
     $flags = 0;
     if ($scm_getpaths) {
         $flags = $flags | SVN_DISCOVER_CHANGED_PATHS;
     }
     // get log
     $svnlog = svn_log($scm_url, SVN_REVISION_INITIAL, SVN_REVISION_HEAD, $scm_limit, $flags);
     $returnarray = array();
     foreach ($svnlog as $ent) {
         if (array_key_exists('paths', $ent)) {
             $files = count($ent['paths']);
         } else {
             $files = 0;
         }
         // Get date and time
         $date = substr($ent['date'], 0, 4) . substr($ent['date'], 5, 2) . substr($ent['date'], 8, 2);
         $time = substr($ent['date'], 11, 8);
         $aent = new scm_logentry($ent['rev'], $ent['author'], $date, $time, $files, $ent['msg']);
         $returnarray[] = $aent;
     }
     $svnlog = null;
     // quick and dirty
     return $returnarray;
 }
Exemplo n.º 2
0
 function start($args)
 {
     print_r($args);
     list($cmd, $this->repos, $this->rev, $this->email) = $args;
     if ($this->repos[0] == '/') {
         $this->repos = $this->repos = 'file://' . $this->repos;
     }
     $this->rev = (int) $this->rev;
     $last = $this->rev - 1;
     // techncially where the diff is!?
     require_once 'System.php';
     $svn = System::which('svn', '/usr/bin/svn');
     $cmd = "{$svn} diff -r{$last}:{$this->rev} {$this->repos}";
     $this->log = svn_log($this->repos, $this->rev, $this->rev - 1, 0, SVN_DISCOVER_CHANGED_PATHS);
     $syntax = $this->checkSyntax();
     //echo $cmd;
     $diff = `{$cmd}`;
     $diff = $this->log[0]['msg'] . "\n\n" . $diff;
     if ($syntax) {
         $diff = $syntax . "\n\n" . $diff;
     }
     $bits = explode('@', $this->email);
     $headers['From'] = "{$this->log[0]['author']} <{$this->log[0]['author']}@{$bits[1]}>";
     $headers['To'] = $this->email;
     $headers['Subject'] = "[SVN {$bits[1]}] " . ($syntax ? "ERROR!" : "") . $this->getFilenames() . " ({$this->rev})";
     $headers['Date'] = date('r');
     $headers['X-Mailer'] = 'svn hook';
     // Create the mail object using the Mail::factory method
     require_once 'Mail.php';
     $mail_object =& Mail::factory('smtp', $params);
     $mail_object->send($this->email, $headers, $diff);
     $this->sendPopup($syntax);
 }
Exemplo n.º 3
0
function admin_svn_log($user, $path)
{
    $userdata = setup_paths($user);
    $svn_url = "file://" . $userdata['svn'] . "/" . $path;
    $ws_url = $userdata['workspace'];
    $revert_possible = !is_dir($ws_url);
    $svn_log = svn_log($svn_url);
    if (empty($svn_log)) {
        ?>
		<p>Path <b><?php 
        echo $path;
        ?>
</b> is not on SVN repository.</p>
		<?php 
        if (file_exists($ws_url)) {
            print "<p>Kontaktirajte administratora!</p>\n";
        }
    }
    print "<ul class=\"svn_log\">\n";
    foreach ($svn_log as $entry) {
        ?>
		<li class="svn_log_entry">(r<?php 
        echo $entry['rev'];
        ?>
) <?php 
        echo date("d. m. Y. H:i:s", strtotime($entry['date']));
        ?>
 - <?php 
        echo $entry['msg'];
        ?>
			<ul>
		<?php 
        foreach ($entry['paths'] as $svnpath) {
            $the_path = $svnpath['path'];
            if ($the_path[0] == "/") {
                $the_path = substr($the_path, 1);
            }
            ?>
			<li><a href="?user=<?php 
            echo $user;
            ?>
&amp;path=<?php 
            echo urlencode($the_path);
            ?>
&amp;svn_rev=<?php 
            echo $entry['rev'];
            ?>
"><?php 
            echo $svnpath['path'];
            ?>
</a></li>
			<?php 
        }
        print "</ul></li>\n";
    }
}
Exemplo n.º 4
0
 function start($args)
 {
     print_r($args);
     list($cmd, $this->repos, $this->rev, $this->target) = $args;
     if (empty($this->target)) {
         echo "NO TARGET !";
         exit;
     }
     if ($this->repos[0] == '/') {
         $this->repos = 'file://' . $this->repos;
     }
     $this->rev = (int) $this->rev;
     $ar = svn_log($this->repos, $this->rev, $this->rev - 1, 0, SVN_DISCOVER_CHANGED_PATHS);
     //print_R($ar);
     foreach ($ar[0]['paths'] as $action) {
         $this->processAction($action);
     }
 }
 */
// FIXME svn stuff still using optc etc, won't work, needs updating!
if ($_SESSION['userlevel'] >= 5) {
    // Note. $device_config_file defined in device.inc.php
    print_optionbar_start();
    $show_menu = '<strong>设置</strong> &#187; ';
    if (!$vars['rev']) {
        $show_menu .= '<span class="pagemenu-selected">';
        $show_menu .= generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
        $show_menu .= '</span>';
    } else {
        $show_menu .= generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
    }
    if (check_extension_exists('svn')) {
        $sep = ' | ';
        $svnlogs = svn_log($device_config_file, SVN_REVISION_HEAD, NULL, 8);
        $revlist = array();
        foreach ($svnlogs as $svnlog) {
            $show_menu .= $sep;
            $revlist[] = $svnlog['rev'];
            if ($vars['rev'] == $svnlog['rev']) {
                $show_menu .= '<span class="pagemenu-selected">';
            }
            $linktext = 'r' . $svnlog['rev'] . ' <small>' . format_timestamp($svnlog['date']) . '</small>';
            $show_menu .= generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev']));
            if ($vars['rev'] == $svnlog['rev']) {
                $show_menu .= '</span>' . PHP_EOL;
            }
        }
    }
    echo $show_menu;
Exemplo n.º 6
0
 function getLog($path, $startRev = null, $endRev = null)
 {
     wfSuppressWarnings();
     $log = svn_log($this->mRepoPath . $path, $this->_rev($startRev, SVN_REVISION_INITIAL), $this->_rev($endRev, SVN_REVISION_HEAD));
     wfRestoreWarnings();
     return $log;
 }
Exemplo n.º 7
0
 /**
  *
  * 调用svn或git的log,获取版本号和更新文字日志
  * @param $src_path 地址
  * @param $type='svn' svn或者git
  * @param $auth=null  帐号密码
  * @param $limit=10 数量
  * @param $last=''  从某版本开始查询
  */
 public function get_log($src_path, $type = 'svn', $auth = null, $limit = 10, $last = '')
 {
     //如果last没指定,则取最新limit个
     //如果指定了,则取limit+1个,去掉last
     $out = array();
     switch ($type) {
         case 'svn':
             if (function_exists('svn_log')) {
                 if ($auth) {
                     svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, $auth['username']);
                     svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, $auth['password']);
                 }
                 if ($last) {
                     $_return = svn_log($src_path, $last, 1, $limit + 1, SVN_STOP_ON_COPY);
                 } else {
                     $_return = svn_log($src_path, null, null, $limit, SVN_STOP_ON_COPY);
                 }
                 foreach ($_return as $_log) {
                     $out[$_log['rev']] = "{$_log['author']}:{$_log['msg']}";
                 }
             } else {
                 $cmd = "svn log {$src_path} --xml --non-interactive --stop-on-copy";
                 if (!empty($auth)) {
                     $cmd .= " --username {$auth['username']} --password {$auth['password']}";
                 }
                 if ($last) {
                     $cmd .= " -r {$last}:1 --limit " . ($limit + 1);
                 } else {
                     $cmd .= " --limit {$limit}";
                 }
                 $cmdresult = exec($cmd);
                 $loadxml = simplexml_load_string(trim($cmdresult), 'SimpleXMLElement', LIBXML_NOCDATA);
                 foreach ($loadxml->children() as $elem) {
                     $out[(string) $elem->attributes()->revision] = $elem->author . ":" . $elem->msg;
                 }
             }
             if ($last && isset($out[$last])) {
                 unset($out[$last]);
             }
             return $out;
         case 'git':
             break;
         default:
             return null;
     }
 }
Exemplo n.º 8
0
     }
     // end if
 }
 echo '<div style="clear: both;">';
 print_optionbar_start('', '');
 echo "<span style='font-weight: bold;'>Config</span> &#187; ";
 if (!$vars['rev']) {
     echo '<span class="pagemenu-selected">';
     echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
     echo '</span>';
 } else {
     echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
 }
 if (function_exists('svn_log')) {
     $sep = ' | ';
     $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8);
     $revlist = array();
     foreach ($svnlogs as $svnlog) {
         echo $sep;
         $revlist[] = $svnlog['rev'];
         if ($vars['rev'] == $svnlog['rev']) {
             echo '<span class="pagemenu-selected">';
         }
         $linktext = 'r' . $svnlog['rev'] . ' <small>' . date($config['dateformat']['byminute'], strtotime($svnlog['date'])) . '</small>';
         echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev']));
         if ($vars['rev'] == $svnlog['rev']) {
             echo '</span>';
         }
         $sep = ' | ';
     }
 }
Exemplo n.º 9
0
         $file = $configs . $device['hostname'];
     }
 }
 echo '<div style="clear: both;">';
 print_optionbar_start('', '');
 echo "<span style='font-weight: bold;'>Config</span> &#187; ";
 if (!$vars['rev']) {
     echo '<span class="pagemenu-selected">';
     echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
     echo "</span>";
 } else {
     echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'));
 }
 if (function_exists('svn_log')) {
     $sep = " | ";
     $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8);
     $revlist = array();
     foreach ($svnlogs as $svnlog) {
         echo $sep;
         $revlist[] = $svnlog["rev"];
         if ($vars['rev'] == $svnlog["rev"]) {
             echo '<span class="pagemenu-selected">';
         }
         $linktext = "r" . $svnlog["rev"] . " <small>" . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . "</small>";
         echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]));
         if ($vars['rev'] == $svnlog["rev"]) {
             echo "</span>";
         }
         $sep = " | ";
     }
 }
Exemplo n.º 10
0
function update_stats($username)
{
    global $username, $conf_svn_path, $stats, $prefix, $vrijeme_kreiranja, $svn_ignore, $vrijeme_limit, $skip_diff, $file_content_limit;
    //print "AŽURIRAMO...\n";
    // Uzimamo log sa SVNa
    $svn_path = "file://" . $conf_svn_path . "/" . $username . "/";
    $svn_log = svn_log($svn_path, SVN_REVISION_HEAD, $stats['last_update_rev']);
    if (!$svn_log || empty($svn_log)) {
        return;
    }
    foreach ($svn_log as &$entry) {
        $entry['unixtime'] = strtotime($entry['date']);
    }
    usort($svn_log, "svnsort");
    $last_time = $old_time = 0;
    $last_deletion = $last_addition = array("time" => 0);
    foreach ($svn_log as $entry) {
        $stats['last_update_rev'] = $entry['rev'];
        // Jedan entry može obuhvaćati više datoteka
        foreach ($entry['paths'] as $path) {
            //print "Path $path\n"
            // svn_diff funkcija ne radi :(
            /*list($diff, $errors) = svn_diff($svn_path, $rev, $svn_path, $old_rev);
            		if ($diff) {
            			$contents = '';
            			while (!feof($diff)) {
            				$contents .= fread($diff, 8192);
            			}
            			fclose($diff);
            			fclose($errors);
            			$log_zapisi[$old_rev]['diff'] = $contents;
            		}*/
            $filepath = $path['path'];
            if (substr($filepath, 0, strlen($prefix) + 1) !== "{$prefix}/") {
                //print "Greska: nije iz prefixa!\n";
                continue;
            }
            $filepath = substr($filepath, strlen($prefix) + 1);
            $svn_file_path = $svn_path . $filepath;
            // Specijalno procesiranje za login i logout
            if ($filepath == ".login") {
                $ftime = strtotime(svn_cat($svn_file_path, $entry['rev']));
                array_push($stats['global_events'], array("time" => $entry['unixtime'], "real_time" => $ftime, "text" => "login"));
                continue;
            }
            if ($filepath == ".logout") {
                $ftime = strtotime(svn_cat($svn_file_path, $entry['rev']));
                array_push($stats['global_events'], array("time" => $entry['unixtime'], "real_time" => $ftime, "text" => "logout"));
                continue;
            }
            // Ostali eventi
            // Praćenje vremena
            $old_time = $last_time;
            $last_time = $entry['unixtime'];
            // Sjeckamo put na dijelove
            $path_parts = explode("/", $filepath);
            $ignored = false;
            foreach ($path_parts as $part) {
                if (in_array($part, $svn_ignore)) {
                    $ignored = true;
                }
            }
            if ($ignored) {
                continue;
            }
            // Ignorisani putevi
            // Kompajliranje/pokretanje/autotest - event pridružujemo parent folderu
            $compiled = $runned = $tested = false;
            $filename = end($path_parts);
            if ($filename == ".gcc.out") {
                $compiled = true;
                if (count($path_parts) > 1) {
                    array_pop($path_parts);
                    $filepath = substr($filepath, 0, strlen($filepath) - strlen("/.gcc.out"));
                }
            } else {
                if ($filename == "runme" || $filename == ".runme") {
                    $runned = true;
                    if (count($path_parts) > 1) {
                        array_pop($path_parts);
                        $filepath = substr($filepath, 0, strlen($filepath) - strlen($filename) - 1);
                    }
                } else {
                    if ($filename == ".at_result") {
                        $tested = true;
                        if (count($path_parts) > 1) {
                            array_pop($path_parts);
                            $filepath = substr($filepath, 0, strlen($filepath) - strlen("/.at_result"));
                        }
                    } else {
                        if ($path['action'] == "M" || $path['action'] == "R") {
                            $diff = true;
                            foreach ($skip_diff as $cpattern) {
                                if (preg_match($cpattern, $filename)) {
                                    $diff = false;
                                }
                            }
                            if ($diff) {
                                $rev = $entry['rev'];
                                $old_rev = $stats[$filepath]['last_revision'];
                                $scpath = str_replace(" ", "\\ ", $svn_file_path);
                                $scpath = str_replace(")", "\\)", $svn_file_path);
                                $scpath = str_replace("(", "\\(", $svn_file_path);
                                $diff_contents = `svn diff {$scpath}@{$old_rev} {$scpath}@{$rev}`;
                                $diff_result = compressed_diff($diff_contents);
                            }
                        }
                    }
                }
            }
            // Praćenje ukupnog vremena rada
            if ($last_time - $old_time < $vrijeme_limit) {
                $vrijeme_zadatka = $last_time - $old_time;
            } else {
                $vrijeme_zadatka = $vrijeme_limit;
            }
            // ?? ispade da se više isplati raditi sporo?
            //print "$filepath last_time $last_time old_time $old_time vrijeme_zadatka $vrijeme_zadatka\n";
            // Rekurzivno ažuriramo sve nadfoldere
            $subpaths = array();
            foreach ($path_parts as $part) {
                if (!empty($subpaths)) {
                    $part = $subpaths[count($subpaths) - 1] . "/{$part}";
                }
                array_push($subpaths, $part);
            }
            // Kreiramo sve nadfoldere ako ne postoje
            $kreiran = false;
            foreach ($subpaths as $subpath) {
                // Ako nije ranije postojao put, kreiramo ga
                if (!array_key_exists($subpath, $stats)) {
                    $stats[$subpath] = array("total_time" => $vrijeme_kreiranja, "builds" => 0, "builds_succeeded" => 0, "testings" => 0, "last_test_results" => "", "events" => array(), "last_revision" => $entry['rev'], "entries" => array());
                    //print "Kreiram novi node $subpath vrijeme $vrijeme_kreiranja\n";
                    // Akcije vezane za kreiranje finalnog puta
                    if ($subpath == $filepath) {
                        // Da li je ovo rename?
                        $this_folder = substr($subpath, 0, strlen($subpath) - strlen($filename));
                        if ($entry['unixtime'] - $last_deletion['time'] < 3 && $this_folder == $last_deletion['folder'] && $filepath != $last_deletion['filepath']) {
                            // print "-- detektovan rename\n";
                            $delpath = $last_deletion['filepath'];
                            array_pop($stats[$delpath]['events']);
                            // Brišemo event brisanja
                            array_push($stats[$subpath]['events'], array("time" => $entry['unixtime'], "text" => "rename", "filename" => $filename, "old_filename" => $last_deletion['filename'], "old_filepath" => $last_deletion['filepath']));
                            $last_deletion = array("time" => 0);
                        } else {
                            if ($entry['unixtime'] - $last_deletion['time'] < 3 && $filename == $last_deletion['filename'] && $filepath != $last_deletion['filepath']) {
                                // print "-- detektovan move\n";
                                $delpath = $last_deletion['filepath'];
                                array_pop($stats[$delpath]['events']);
                                // Brišemo event brisanja
                                array_push($stats[$subpath]['events'], array("time" => $entry['unixtime'], "text" => "move", "filename" => $filename, "old_filename" => $last_deletion['filename'], "old_filepath" => $last_deletion['filepath']));
                                $last_deletion = array("time" => 0);
                            } else {
                                // Nije rename
                                $text = "created";
                                $scpath = str_replace(" ", "%20", $svn_file_path);
                                $content = @svn_cat($scpath, $entry['rev']);
                                $lastError = error_get_last();
                                if (strstr($lastError['message'], "refers to a directory")) {
                                    // print "Ovo je direktorij\n";
                                    $text = "created_folder";
                                } else {
                                    if (strstr($lastError['message'], "File not found") || strstr($lastError['message'], "Unable to find repository")) {
                                        // Funkcija svn_cat nekad radi nekad ne radi :( neobjašnjivo
                                        $scpath = str_replace(" ", "\\ ", $svn_file_path);
                                        $cmd = "svn cat {$scpath}@" . $entry['rev'] . " 2>&1";
                                        $content = `{$cmd}`;
                                        if (strstr($content, "refers to a directory")) {
                                            $text = "created_folder";
                                        }
                                    } else {
                                        if (!strstr($lastError['message'], "Undefined variable: undef_var")) {
                                            print "Neka nova greška: " . $lastError['message'] . "\n";
                                        }
                                    }
                                }
                                // Resetovanje PHP grešaka
                                set_error_handler('var_dump', 0);
                                @$undef_var;
                                restore_error_handler();
                                // Detekcija binarne datoteke preko magic-a
                                if (substr($content, 1, 3) == "ELF") {
                                    $content = "binary";
                                }
                                // Fajlovi čiji sadržaj ne uzimamo
                                $skip_content = false;
                                foreach ($skip_diff as $cpattern) {
                                    if (preg_match($cpattern, $filename)) {
                                        $skip_content = true;
                                    }
                                }
                                if ($skip_content) {
                                    $content = "binary";
                                }
                                // Skraćujemo datoteke >100k
                                if (strlen($content) > $file_content_limit) {
                                    $content = substr($content, 0, 100000) . "...";
                                }
                                // Dodajemo evenet
                                array_push($stats[$subpath]['events'], array("time" => $entry['unixtime'], "text" => $text, "filename" => $filename, "content" => $content));
                                $kreiran = true;
                                // Ako je u pitanju kreiranje finalnog puta, nećemo povećavati vrijeme svih nadfoldera
                                // Ovo se nažalost mora uraditi ovako jer su folderi složeni od viših ka nižim jer je to
                                // prirodan redoslijed kreiranja (ako nisu postojali ranije)
                                foreach ($subpaths as $subpath2) {
                                    if ($stats[$subpath2]['total_time'] > $vrijeme_kreiranja && $stats[$subpath2]['total_time'] > $vrijeme_zadatka) {
                                        $stats[$subpath2]['total_time'] -= $vrijeme_zadatka;
                                        //print "Smanjujem vrijeme za $subpath2 za $vrijeme_zadatka\n";
                                    }
                                }
                                // Praćenje move/rename akcija
                                $foulder = substr($filepath, 0, strlen($filepath) - strlen($filename));
                                $last_addition = array("time" => $entry['unixtime'], "filepath" => $filepath, "filename" => $filename, "folder" => $foulder);
                            }
                        }
                    } else {
                        // Nadfolder
                        array_push($stats[$subpath]['events'], array("time" => $entry['unixtime'], "text" => "created", "filename" => $filename));
                    }
                    $kreiran = true;
                } else {
                    $stats[$subpath]['total_time'] += $vrijeme_zadatka;
                    //print "Povećavam vrijeme za $subpath za $vrijeme_zadatka\n";
                }
            }
            // Ažuriramo entries
            $previous = "";
            foreach (array_reverse($subpaths) as $subpath) {
                if ($previous != "") {
                    if (!in_array($previous, $stats[$subpath]['entries'])) {
                        array_push($stats[$subpath]['entries'], $previous);
                    }
                }
                $previous = $subpath;
            }
            // Dodajemo event na stavku
            end($stats[$filepath]['events']);
            $lastk = key($stats[$filepath]['events']);
            $last_event =& $stats[$filepath]['events'][$lastk];
            $stats[$filepath]['last_revision'] = $entry['rev'];
            // Brisanje
            if ($path['action'] == "D") {
                if ($entry['unixtime'] - $last_addition['time'] < 3 && $this_folder == $last_addition['folder'] && $filepath != $last_addition['filepath']) {
                    // Rename
                    end($stats[$last_addition['filepath']]['events']);
                    $lastk = key($stats[$last_addition['filepath']]['events']);
                    $last_event =& $stats[$last_addition['filepath']]['events'][$lastk];
                    $addpath = $last_addition['filepath'];
                    $last_event['text'] = "rename";
                    $last_event['old_filename'] = $filename;
                    $last_event['old_filepath'] = $filepath;
                    $last_addition = array("time" => 0);
                } elseif ($entry['unixtime'] - $last_addition['time'] < 3 && $filename == $last_addition['filename'] && $filepath != $last_addition['filepath']) {
                    // Move
                    end($stats[$last_addition['filepath']]['events']);
                    $lastk = key($stats[$last_addition['filepath']]['events']);
                    $last_event =& $stats[$last_addition['filepath']]['events'][$lastk];
                    $addpath = $last_addition['filepath'];
                    $last_event['text'] = "move";
                    $last_event['old_path'] = $filepath;
                    $last_addition = array("time" => 0);
                } else {
                    // Fajl obrisan
                    array_push($stats[$filepath]['events'], array("time" => $entry['unixtime'], "text" => "deleted"));
                    $foulder = substr($filepath, 0, strlen($filepath) - strlen($filename));
                    $last_deletion = array("time" => $entry['unixtime'], "filepath" => $filepath, "filename" => $filename, "folder" => $foulder);
                }
                // Kompajliranje
            } else {
                if ($compiled) {
                    $stats[$filepath]['builds']++;
                    if ($last_event['text'] == "compiled successfully" && abs($last_event['time'] - $entry['unixtime']) < 3) {
                        // Samo ćemo dodati izlaz kompajlera na runme
                        $scpath = str_replace(" ", "%20", $svn_file_path);
                        $last_event['output'] = svn_cat($scpath, $entry['rev']);
                        // print "Rev: ".$entry['rev']." OUTPUT:\n".$last_event['output']."\n";
                    } else {
                        // Za sada ne znamo da li je uspješno pokrenut program
                        $scpath = str_replace(" ", "%20", $svn_file_path);
                        $output = svn_cat($scpath, $entry['rev']);
                        array_push($stats[$filepath]['events'], array("time" => $entry['unixtime'], "text" => "compiled", "output" => $output, "rev" => $entry['rev']));
                    }
                    // Uspješno kompajliranje
                } else {
                    if ($runned) {
                        $stats[$filepath]['builds_succeeded']++;
                        if ($last_event['text'] == "compiled" && abs($last_event['time'] - $entry['unixtime']) < 3) {
                            // Ako već postoji gcc output, samo ćemo označiti da je uspješno
                            $last_event['text'] = "compiled successfully";
                        } else {
                            array_push($stats[$filepath]['events'], array("time" => $entry['unixtime'], "text" => "compiled successfully", "rev" => $entry['rev']));
                        }
                        // Pokrenut buildservice za autotestove
                    } else {
                        if ($tested) {
                            $stats[$filepath]['testings']++;
                            // Rezultati testiranja
                            $scpath = str_replace(" ", "%20", $svn_file_path);
                            $rezultati_testova = json_decode(svn_cat($scpath, $entry['rev']), true);
                            $svn_test_path = $svn_path . $filepath . "/.autotest";
                            $scpath = str_replace(" ", "%20", $svn_test_path);
                            $testovi = json_decode(svn_cat($scpath, $entry['rev']), true);
                            $ukupno_testova = count($testovi['test_specifications']);
                            $uspjesnih_testova = 0;
                            foreach ($rezultati_testova['test_results'] as $test) {
                                if ($test['status'] == 1) {
                                    $uspjesnih_testova++;
                                }
                            }
                            $stats[$filepath]['last_test_results'] = "{$uspjesnih_testova}/{$ukupno_testova}";
                            array_push($stats[$filepath]['events'], array("time" => $entry['unixtime'], "text" => "ran tests", "test_results" => "{$uspjesnih_testova}/{$ukupno_testova}"));
                            // Izmjena fajla
                        } else {
                            if ($path['action'] != "A") {
                                array_push($stats[$filepath]['events'], array("time" => $entry['unixtime'], "text" => "modified", "diff" => $diff_result));
                                // SVN je registrovao kreiranje za put koji već imamo u statistici - dodajemo event "created"
                            } else {
                                if (!$kreiran) {
                                    array_push($stats[$filepath]['events'], array("time" => $entry['unixtime'], "text" => "created", "filename" => $filename));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 11
0
$url = $config['svn_repos'];
$dsn = "mysql:host={$db_host};dbname={$db_name}";
$dbh = new PDO($dsn, $db_user, $db_password);
$sql0 = "SELECT * FROM `configuration` WHERE `option` = 'revision'";
$sth0 = $dbh->prepare($sql0);
$sth0->execute();
$result = $sth0->fetch(PDO::FETCH_OBJ);
$revision = $result->value;
$sql1 = "INSERT INTO svn_revision_log (revision, author, commit_msg, commit_time, file_changed) VALUES (?, ?, ?, ?, ?)";
$sth1 = $dbh->prepare($sql1);
$sql2 = "INSERT INTO svn_commit_log (revision, action, path) VALUES (?, ?, ?)";
$sth2 = $dbh->prepare($sql2);
// or use $to_revision = $revision + 1000 to fetch log each time.
echo "from {$revision} to SVN_REVISION_HEAD\n";
$array = array();
$array = svn_log($url, $revision, SVN_REVISION_HEAD);
foreach ($array as $row) {
    if (!empty($row)) {
        if ($row['rev'] == $revision) {
            continue;
        }
        $time = strtotime($row['date']);
        $datetime = date('Y-m-d H:i:s', $time);
        $sth1->execute(array($row['rev'], $row['author'], $row['msg'], $datetime, count($row['paths'])));
        foreach ($row['paths'] as $sub_row) {
            if (!empty($sub_row)) {
                $sth2->execute(array($row['rev'], $sub_row['action'], $sub_row['path']));
            }
        }
        $revision = $row['rev'];
    }
Exemplo n.º 12
0
<?php

include './Header.php';
echo '<h1>Gestor de Actualizaciones</h1>';
echo '<p>Buscar e instalar. <a href="?doUpdate=true">&raquo; Actualizaciones...?</a></p>';
$doUpdate = filter_input(INPUT_GET, "doUpdate");
svn_auth_set_parameter(PHP_SVN_AUTH_PARAM_IGNORE_SSL_VERIFY_ERRORS, TRUE);
svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, "lupe");
svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, "ggarza.");
if ($doUpdate) {
    $x = svn_update(filter_input(INPUT_SERVER, "CONTEXT_DOCUMENT_ROOT"), SVN_REVISION_HEAD, TRUE);
    echo 'Actualizado a la revision: ' . $x;
    echo '<br>';
}
echo '<p><h2>Log de Cambios</h2>';
$aLog = svn_log(filter_input(INPUT_SERVER, "CONTEXT_DOCUMENT_ROOT"), SVN_REVISION_PREV, SVN_REVISION_HEAD);
foreach ($aLog as $rev) {
    ?>
    <div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title">Revision # <?php 
    echo $rev['rev'];
    ?>
</h3>
        </div>
        <div class="panel-body">
            Por: <?php 
    echo $rev['author'];
    ?>
<br>
            Mensaje: <?php 
Exemplo n.º 13
0
</b></td>
						</tr>
						<?php 
            }
        }
        ?>
			</table>
			<?php 
        echo "<br/><br/><b>Files in your working copy have been modified as shown above. Updates are disabled to prevent conflicts. It is recommended that you implement your modifications as plugins to enable web-based updates.</b>";
    } else {
        $clean = true;
        echo "<br/><br/><b>Your working copy is clean at revision {$svnrevision}. Congratulations! ";
        // flush now as svn_log can take time.
        flush();
        // grab a log to see if updates are available
        $svnlog = svn_log("http://svn.resourcespace.org/svn/resourcespace", SVN_REVISION_HEAD, $svnrevision + 0);
        if (count($svnlog) > 1) {
            echo "<br/><br/>The following Updates are available";
            ?>
				<br/>
				<br/>
				<table class="InfoTable">
					<?php 
            for ($n = 0; $n < count($svnlog); $n++) {
                if (isset($svnlog[$n])) {
                    ?>
							<tr>
								<td><a href="svnup.php?rev=<?php 
                    echo $svnlog[$n]["rev"];
                    ?>
">&gt;&nbsp;<?php 
Exemplo n.º 14
0
 /**
  * Retrieve file 's history
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  File resource
  * @param  string path
  * @return array
  * @see core_kernel_versioning_File::gethistory()
  */
 public function getHistory(core_kernel_file_File $resource, $path)
 {
     $returnValue = array();
     $startTime = helpers_Time::getMicroTime();
     if ($resource->getRepository()->authenticate()) {
         $returnValue = svn_log($path);
     }
     $endTime = helpers_Time::getMicroTime();
     common_Logger::i('svn_getHistory (' . $path . ') -> ' . ($endTime - $startTime) . 's');
     return (array) $returnValue;
 }