#!/usr/bin/php $meta) { chdir($workdir) || die("failed chdir\n"); $output = null; $url = @$meta['git']; $branch = @$meta['branch']; $branch_arg = $branch ? sprintf('--branch %s', escapeshellarg($branch)) : ''; $cmd = sprintf('git clone %s --depth=1 %s %s', $branch_arg, escapeshellarg($url), escapeshellarg($crate)); shell($cmd) && die("git clone failed\n command was: $cmd\n"); $cratedir = $crate . '/' . @$meta['path']; $src_url_mask = ""; if(strstr($url, "github.com")) { $src_url_mask = sprintf("%s/blob/master/{file}", $url); } // Get date of last commit chdir($cratedir) || die("failed chdir to '$cratedir'\n"); exec("git log -1 --format=\%cd", $output, $rc); if($rc) { die("git log failed\n"); } $last_commit_date = date('Y-m-d', @strtotime(trim(implode("\n", $output)))); $crate_dates[$crate] = $last_commit_date; $cratepaths[] = sprintf("%s[::]%s", escapeshellarg(sprintf("%s/%s", $workdir, $cratedir)), escapeshellarg($src_url_mask)); echo "\n"; } $cmd = sprintf("%s/gen_diagrams.php %s %s", escapeshellcmd(__DIR__), escapeshellarg($diagrams_dir), implode(' ', $cratepaths)); shell($cmd) && die("\n"); gen_html_index($diagrams_dir, $json, $crate_dates); echo "\nFinished. Diagrams are in $diagrams_dir\n"; exit(0); function shell($cmd) { echo "executing cmd: $cmd\n"; passthru($cmd, $rc); return $rc; } function gen_html_index($diagrams_dir, $json, $crate_dates) { $buf = <<< END
Crate | Diagrams | References | Last Commit | ||||
%s | bare | compact | full | repo | crates.io | docs.rs | %s |