MTrackWeb/Merger.php
[web.mtrack] / MTrackWeb / Merger.php
1 <?php
2 /**
3  * concept is to merge commits from a live or working tree
4  * into the 'release tree'
5  *
6  *
7  * step 1 = render the log of differences..
8  *
9  */
10
11 require_once 'MTrackWeb/Log.php';
12
13 class MTrackWeb_Merger extends MTrackWeb_Log {
14     
15     
16     // function getAuth() - from log..
17     
18     
19     function get($pi)
20     {
21         
22         $this->pi = empty($pi) ? '' : ($pi . $this->bootLoader->ext);
23          $this->repo = DB_DataObject::factory('mtrack_repos');
24         $this->filename = $this->repo->loadFromPath($this->pi);
25         
26         
27        
28         if (!$this->repo->id) {
29             return HTML_FlexyFramework::run('Browse');  
30         };
31           
32         if (!$this->projectPerm($this->repo->project_id, 'MTrack.Repos', 'S')) {
33             return HTML_FlexyFramework::run('Noperm');  // noperm = loggedin -> need more perms / not.. try loggin in..
34         }
35           
36          
37         $live = 'master';
38         $release = 'github';
39          
40         $this->repo->debug = 1;
41         $ar = $this->repo->history("/", 10, "rev",  "$release..$live");
42         //echo '<PRE>';print_R($ar);
43         
44         // need to get a 2 dimensional array of
45         // files along top, and commints down.
46         $cfiles = array();
47         foreach($ar as $commit) {
48             $files = $commit->files;
49             $row = array(
50                 'commit' => $commit->ctime,
51                 'desc' => $commit->changelog
52             );
53             foreach($files as $f=>$data) {
54                 $row[$f] = $commit->rev;
55                 $cfiles[$f] = true;
56             }
57             $rows[] = $row;
58         }
59         // this might result in alot of white boxes where you can
60         // let's see what it looks like..
61         echo '<PRE>';print_R($cfiles);
62         echo '<PRE>';print_R($rows);
63         die("done");
64         
65         
66         
67         
68     }
69     
70     
71     
72 }