-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgit-utils.inc.php
More file actions
43 lines (39 loc) · 914 Bytes
/
git-utils.inc.php
File metadata and controls
43 lines (39 loc) · 914 Bytes
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
<?php
require_once('config.inc.php');
function run_git($command, $repo, $bare=false)
{
$repo = str_replace('/', '', $repo);
$repo = str_replace('\\', '', $repo);
if (!$bare)
$repo.='/.git';
$output = array();
$ret = 0;
$c = GIT_EXEC.' --git-dir='.ROOT_DIR.$repo.' '.$command;
exec($c, $output, $ret);
if ($ret != 0) {
//debug
echo($c);
die('git failed, is git path correct?');
}
return $output;
}
function git_get_log($repo, $limit = 10, $bare=false)
{
$format = array('%H', '%at', '%an', '%s');
$params = implode(DELIMETER, $format);
$data = run_git('log --pretty=format:"'.$params.'" -'.$limit, $repo, $bare);
$result = array();
foreach($data as $line)
{
$columns = explode(DELIMETER, $line);
$row = array(
'commit' => $columns[0],
'timestamp' => $columns[1],
'author' => $columns[2],
'message' => $columns[3],
);
$result[] = $row;
}
return $result;
}
?>