3 * concept is to merge commits from a live or working tree
4 * into the 'release tree'
7 * step 1 = render the log of differences..
11 * -- our doc commit changes loads of files.. and makes the layout pointless.
12 * -- ?? grouping by day??? // expand/collapse..
17 require_once 'Pman.php';
19 class Pman_MTrack_Merger extends Pman {
21 $this->live = 'master';
22 $this->release = 'github';
23 // function getAuth() - from log..
27 $au = $this->getAuthUser();
28 if (!$au || $au->company()->comptype != 'OWNER') {
31 $this->authUser = $au;
39 $this->pi = 'default/roojs1'; // fixme..
41 $this->repo = DB_DataObject::factory('mtrack_repos');
42 $this->filename = $this->repo->loadFromPath($this->pi);
44 if (!$this->repo->id) {
45 $this->err("invalid repo");
48 //if (!$this->projectPerm($this->repo->project_id, 'MTrack.Repos', 'S')) {
49 // $this->err("no perm for this repo ");
51 if (isset($_REQUEST['_tree'])) {
55 if (isset($_REQUEST['_changedFiles'])) {
56 $this->changedFiles($_REQUEST['_changedFiles']);
58 $this->jerr("invalid url");
71 $this->repo->debug = 1;
72 $ar = $this->repo->history("/", null, "rev", "{$this->release}..{$this->live}");
74 // the point of this is to extract all the revisions, and group them.
78 //echo '<PRE>';print_R($ar);
80 // need to get a 2 dimensional array of
81 // files along top, and commints down.
84 foreach($ar as $commit) {
86 $files = $commit->files;
87 $day = date("Y-m-d", strtotime($commit->ctime));
88 if (!isset($days[$day])) {
95 $time= date("H:i:s", strtotime($commit->ctime));
96 if (!isset($days[$day]['children'][$time])) {
97 $days[$day]['children'][$time] = array(
99 'rev' => $day . ' ' . $time,
103 $days[$day]['children'][$time]['children'][] = array(
104 'text'=> $commit->changelog,
105 'rev' => $commit->rev,
111 foreach($days as $d=>$do) {
112 $dcn = $do['children'];
113 $do['children'] = array();
114 foreach($dcn as $t=>$to) {
115 $to['rev'] = $to['children'][0]['rev'];
116 $do['children'][] = $to;
118 $do['rev'] = $do['children'][0]['rev'];
132 function changedFiles($rev)
134 // list the files that have changed..
135 // in theory you could click a number of them and only merge those changes..
136 // need to do a git diff.. and just get a list of files..
138 $rev = preg_replace('/[^a-z0-9]+/', '');
139 $fh = $this->repo->git('diff', "{$this->release}..{$rev}", '--', "");
141 echo stream_get_contents($fh);