1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14: class Horde_Vcs_Patchset_Git extends Horde_Vcs_Patchset_Base
15: {
16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
27: public function __construct($rep, $opts = array())
28: {
29: $revs = array();
30:
31: if (isset($opts['file'])) {
32: $ob = $rep->getFile($opts['file']);
33: $revs = $ob->getLog();
34: } elseif (!empty($opts['range'])) {
35: foreach ($opts['range'] as $val) {
36:
37: list($resource, $stream) = $rep->runCommand('diff-tree --name-only -r ' . escapeshellarg($val));
38:
39:
40: $ob = $rep->getFile(fgets($stream));
41: fclose($stream);
42: proc_close($resource);
43: $revs[$val] = $ob->getLog($val);
44: }
45: }
46:
47: reset($revs);
48: while (list($rev, $log) = each($revs)) {
49: if (empty($log)) {
50: continue;
51: }
52:
53: $this->_patchsets[$rev] = array_merge(
54: $log->toHash(),
55: array('members' => array())
56: );
57:
58: foreach ($log->getFiles() as $file) {
59: $from = $log->getParent();
60: $to = $rev;
61:
62: switch ($file['status']) {
63: case 'A':
64: $status = Horde_Vcs_Patchset::ADDED;
65: break;
66:
67: case 'D':
68: $status = Horde_Vcs_Patchset::DELETED;
69: break;
70:
71: default:
72: $status = Horde_Vcs_Patchset::MODIFIED;
73: }
74:
75: $statinfo = isset($file['added'])
76: ? array('added' => $file['added'], 'deleted' => $file['deleted'])
77: : array();
78:
79: $this->_patchsets[$rev]['members'][] = array_merge(array(
80: 'file' => $file['srcPath'],
81: 'from' => $from,
82: 'status' => $status,
83: 'to' => $to,
84: ), $statinfo);
85: }
86: }
87: }
88: }
89: