-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommits.php
More file actions
70 lines (62 loc) · 2.12 KB
/
commits.php
File metadata and controls
70 lines (62 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once 'includes/auth.php';
require_once 'includes/database.php';
require_once 'includes/repository.php';
requireLogin();
$repo = $_GET['repo'] ?? null;
$username = $_GET['user'] ?? $_SESSION['username'];
if (!$repo) {
header('Location: dashboard.php');
exit;
}
// Get repository info
$repoInfo = getRepositoryInfo($username, $repo);
if (!$repoInfo || !canAccessRepository($repoInfo)) {
die("Access denied");
}
$repoPath = getRepoPath($username, $repo);
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo htmlspecialchars($repo); ?> - Commits</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php include 'includes/repo-header.php'; ?>
<div class="commit-history">
<?php
$command = "cd " . escapeshellarg($repoPath) .
" && git log --pretty=format:'%H|%h|%an|%ar|%s'";
$log = shell_exec($command);
if ($log) {
foreach(explode("\n", $log) as $line) {
$parts = explode('|', $line);
if (count($parts) === 5) {
list($fullHash, $shortHash, $author, $date, $message) = $parts;
?>
<div class="commit">
<div class="commit-message">
<a href="files.php?<?php echo http_build_query([
'repo' => $repo,
'user' => $username,
'commit' => $fullHash
]); ?>"><?php echo htmlspecialchars($message); ?></a>
</div>
<div class="commit-meta">
<?php echo htmlspecialchars($shortHash); ?> by
<?php echo htmlspecialchars($author); ?> •
<?php echo htmlspecialchars($date); ?>
</div>
</div>
<?php
}
}
} else {
echo "<p>No commits found in this repository.</p>";
}
?>
</div>
</body>
</html>