From: Mischa POSLAWSKY Date: Fri, 15 Jan 2021 09:24:40 +0000 (+0100) Subject: login/commits: git show of hash parameter X-Git-Tag: v5.3~28 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/b4e872adfb3c7b67447826a5b162f89590e14c80 login/commits: git show of hash parameter Link overview to further details, currently unformatted. --- diff --git a/login/commits/index.php b/login/commits/index.php new file mode 100644 index 0000000..c53bf39 --- /dev/null +++ b/login/commits/index.php @@ -0,0 +1,28 @@ +admin('edit')) { + require '403.inc.html'; + return; +} + +$hash = ltrim($Page->path, '/'); +if (!$hash) { + return TRUE; +} + +print "

Wijzigingen in $hash

\n"; + +$gitcmd = "git show ".$hash; +$log = popen($gitcmd, 'r'); +if (!$log or strpos(fgets($log), "commit $hash") !== 0) { + $Page->place['warn'] = "Kon inhoud niet ophalen met $gitcmd"; + return; +} + +print '
';
+while ( $line = fgets($log) ) {
+	print htmlspecialchars($line);
+}
+print "
\n"; + +pclose($log); +return; diff --git a/widget/login/commits.php b/widget/login/commits.php index 18447a7..2060a33 100644 --- a/widget/login/commits.php +++ b/widget/login/commits.php @@ -4,8 +4,9 @@ if (!function_exists('popen')) { return; } +$baseurl = 'login/commits'; $pagesize = intval(@$Page->place['n'] ?: @$_GET['n']) ?: 20; -$gitcmd = "git log -n $pagesize --pretty='%at\t%an\t%s'"; +$gitcmd = "git log -n $pagesize --pretty='%h\t%at\t%an\t%s'"; if ( $offset = intval(@$_GET['start']) ) { $gitcmd .= " --skip=$offset"; @@ -15,12 +16,16 @@ if ( $log = popen($gitcmd, 'r') ) { $lines = 0; print "\n\n"; @@ -29,6 +34,6 @@ if ( $log = popen($gitcmd, 'r') ) { $limit = $offset + $lines + 1; # assume one more print $Page->widget('nav', [ 'start' => $offset, 'n' => $pagesize, 'total' => $limit, - 'link' => $Page->link != 'login/commits' ? 'login/commits' : '', + 'link' => $Page->link == $baseurl ? NULL : $baseurl, ]); }