11
11
($ text = @file_get_contents ($ cratefile )) || die ("failed reading file $ cratefile \n" );
12
12
($ json = @json_decode ($ text , true )) || die ("failed parsing json in $ cratefile \n" );
13
13
14
- chdir ($ workdir ) || die ("failed chdir " );
15
-
16
14
$ cratepaths = [];
15
+ $ crate_dates = [];
17
16
foreach ($ json as $ crate => $ meta ) {
17
+ chdir ($ workdir ) || die ("failed chdir " );
18
+ $ output = null ;
18
19
$ url = @$ meta ['git ' ];
19
20
$ cmd = sprintf ('git clone --depth=1 %s %s ' , escapeshellarg ($ url ), escapeshellarg ($ crate ));
20
21
shell ($ cmd ) && die ("git clone failed \n" );
23
24
if (strstr ($ url , "github.com " )) {
24
25
$ src_url_mask = sprintf ("%s/blob/master/{file} " , $ url );
25
26
}
27
+
28
+ // Get date of last commit
29
+ chdir ("$ cratedir " ) || die ("failed chdir " );
30
+ exec ("git log -1 --format=\%cd " , $ output , $ rc ); if ($ rc ) { die ("git log failed " ); }
31
+ $ last_commit_date = date ('Y-m-d ' , @strtotime (trim (implode ("\n" , $ output ))));
32
+ $ crate_dates [$ crate ] = $ last_commit_date ;
33
+
26
34
$ cratepaths [] = sprintf ("%s[::]%s " ,
27
35
escapeshellarg (sprintf ("%s/%s " , $ workdir , $ cratedir )),
28
36
escapeshellarg ($ src_url_mask ));
37
45
38
46
shell ($ cmd ) && die ("" );
39
47
40
- gen_html_index ($ diagrams_dir , $ json );
48
+ gen_html_index ($ diagrams_dir , $ json, $ crate_dates );
41
49
42
50
echo "\nFinished. Diagrams are in $ diagrams_dir \n" ;
43
51
@@ -48,7 +56,7 @@ function shell($cmd) {
48
56
return $ rc ;
49
57
}
50
58
51
- function gen_html_index ($ diagrams_dir , $ json ) {
59
+ function gen_html_index ($ diagrams_dir , $ json, $ crate_dates ) {
52
60
53
61
$ buf = <<< END
54
62
<html><head><style>
@@ -74,7 +82,7 @@ function gen_html_index($diagrams_dir, $json) {
74
82
<body>
75
83
<table class='diagrams'>
76
84
<thead>
77
- <tr><td>Crate</td><td colspan="3">Diagrams</td><td colspan="3">References</td></tr>
85
+ <tr><td>Crate</td><td colspan="3">Diagrams</td><td colspan="3">References</td><td>Last Commit</td>< /tr>
78
86
</thead>
79
87
END ;
80
88
@@ -88,8 +96,9 @@ function gen_html_index($diagrams_dir, $json) {
88
96
$ compact = sprintf ('%s-compact.svg ' , $ crate );
89
97
$ full = sprintf ('%s.svg ' , $ crate );
90
98
$ class = $ cnt % 2 == 0 ? 'even ' : 'odd ' ;
99
+ $ last_commit_date = @$ crate_dates [$ crate ];
91
100
92
- $ buf .= sprintf ('<tr class="%s"><td>%s</td><td><a href="%s">bare</a></td><td><a href="%s">compact</a></td><td><a href="%s">full</a></td><td><a href="%s">repo</a></td><td><a href="%s">crates.io</a></td><td><a href="%s">docs.rs</a></td></ tr> ' , $ class , $ crate , $ bare , $ compact , $ full , $ url , $ crate_io_url , $ docs_rs_url ) . "\n" ;
101
+ $ buf .= sprintf ('<tr class="%s"><td>%s</td><td><a href="%s">bare</a></td><td><a href="%s">compact</a></td><td><a href="%s">full</a></td><td><a href="%s">repo</a></td><td><a href="%s">crates.io</a></td><td><a href="%s">docs.rs</a></td><td>%s</td></ tr> ' , $ class , $ crate , $ bare , $ compact , $ full , $ url , $ crate_io_url , $ docs_rs_url, $ last_commit_date ) . "\n" ;
93
102
$ cnt ++;
94
103
}
95
104
$ buf .= "</table></body></html> " ;
0 commit comments