blob: 43a85009acd8b956fad5a2fe19a8c3845883b783 (
plain)
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
|
<?php
namespace phorkie;
class Repository_Setup
{
protected $repo;
public function __construct(Repository $repo)
{
$this->repo = $repo;
}
/**
* Should be called right after a repository has been created,
* either by "git init" or "git clone".
* Takes care of removing hook example files and creating
* the git daemon export file
*
* @return void
*/
public function afterInit()
{
foreach (glob($this->repo->gitDir . '/hooks/*') as $hookfile) {
unlink($hookfile);
}
touch($this->repo->gitDir . '/git-daemon-export-ok');
$vc = $this->repo->getVc();
file_put_contents(
$this->repo->gitDir . '/hooks/post-update',
<<<CDE
#!/bin/sh
# Hook script to prepare a packed repository for use over dumb transports.
exec git update-server-info
CDE
);
chmod($this->repo->gitDir . '/hooks/post-update', 0755);
//keep track of owner
$vc->getCommand('config')
->addArgument('owner.name')
->addArgument($_SESSION['name'])
->execute();
$vc->getCommand('config')
->addArgument('owner.email')
->addArgument($_SESSION['email'])
->execute();
}
}
?>
|