-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathupdate_cache.php
More file actions
executable file
·39 lines (33 loc) · 1.01 KB
/
update_cache.php
File metadata and controls
executable file
·39 lines (33 loc) · 1.01 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
#!/usr/bin/env php
<?php
require_once __DIR__ . '/bootstrap.php';
class UpdateCache
{
public function run()
{
$Gitosis = new \GitPHP\Model_Gitosis();
$repositories = $Gitosis->getRepositories();
if ($repositories === false) {
echo date('r') . ": Cannot receive repositories from DB\n";
return;
}
foreach ($repositories as $repository) {
try {
echo date('r') . ": Running for {$repository['project']}\n";
$Project = new \GitPHP\Git\Project($repository['project']);
$Project->UpdateUnmergedCommitsCache();
$Project->UpdateHeadsCache();
} catch (\Exception $e) {
echo date('r') . ": Error: {$e->getMessage()}";
}
}
}
}
$fp = fopen(__DIR__ . "/update_cache.lock", 'w+');
if (!flock($fp, LOCK_EX | LOCK_NB)) {
exit(0);
}
$Application = new GitPHP\Application();
$Application->init();
$Script = new UpdateCache();
$Script->run();