BarryServer : Git

All the code for all my projects
// BarryServer : Git / barryserver-git / blob / a6603d573a369feda0bc772d59bc48c3d1397442 / commit.php

// Related

barryserver-git

Barry Splitting into more pages + commit pages a6603d5 (2 years, 3 months ago)
<?php require_once $_SERVER["DOCUMENT_ROOT"]."/config.php"; ?>
<?php $SIDE_LINKS = array(); ?>
<?php
	if (!isset($_GET["repo"])) {header("Location: /");die();}
	$repo = $_GET["repo"]??"";
	if (isset($_GET["repo"])) {
		$PAGE_TITLE = $repo;
	}

	if (!is_dir(GIT_DIR."/".$repo.".git")) { ?>
<?php require_once $_SERVER["DOCUMENT_ROOT"]."/head.php"; ?>
<main>
	<h1>Repository not found</h1>
	<article>The repository you were looking for was not found on this server. Please check the URL and look for$
</main>
<?php require_once $_SERVER["DOCUMENT_ROOT"]."/foot.php"; ?>
<?php	die();}
	$branch = $_GET["object"]??DEFAULT_BRANCH;
	$path = $_GET["path"]??".";
	chdir(GIT_DIR."/".$repo.".git");
	if ($branch === "") {
		$branch = DEFAULT_BRANCH;
	}
	$SIDE_LINKS["git clone"] = "git://".$_SERVER["SERVER_NAME"]."/".$repo.".git";
	$SIDE_LINKS["Browse Files"] = "/".$repo."/tree/".$branch."/".$path;
	$PAGE_TITLE = "Commit ".substr($branch,0,7)." @ ".$PAGE_TITLE;
	require_once $_SERVER["DOCUMENT_ROOT"]."/head.php";
	echo "<main><h1>".$repo."</h1>\n";
	$lastcommit = shell_exec("git log --summary --quiet --oneline --abbrev-commit --format=format:'<b>%an</b> %s <span><a href=\"/".escapeshellcmd($repo)."/commit/%H/".escapeshellcmd($path)."\">%h</a> (%ar)</span>' -n 1 ".escapeshellarg($branch)." -- ".escapeshellarg($path));
	echo "<span class=\"last-commit\">".$lastcommit."</span>";
	$content = shell_exec("git --git-dir ".GIT_DIR."/".escapeshellcmd($repo).".git/ log --format= -p -n 1 ".escapeshellarg($branch)." -- ".escapeshellarg($path));
	echo "<pre class=\"prettyprint\">\n".htmlspecialchars($content)."</pre>\n";
?>
</main>
<?php require_once $_SERVER["DOCUMENT_ROOT"]."/foot.php"; ?>