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  * First run issues:
11  *  -- our doc commit changes loads of files.. and makes the layout pointless.
12  *  -- ?? grouping by day??? // expand/collapse.. 
13  * 
14  *
15  */
16
17 require_once 'MTrackWeb/Log.php';
18
19 class MTrackWeb_Merger extends MTrackWeb_Log {
20     
21     
22     // function getAuth() - from log..
23     
24     
25     function get($pi)
26     {
27         
28         $this->pi = empty($pi) ? '' : ($pi . $this->bootLoader->ext);
29          $this->repo = DB_DataObject::factory('mtrack_repos');
30         $this->filename = $this->repo->loadFromPath($this->pi);
31         
32         
33        
34         if (!$this->repo->id) {
35             return HTML_FlexyFramework::run('Browse');  
36         };
37           
38         if (!$this->projectPerm($this->repo->project_id, 'MTrack.Repos', 'S')) {
39             return HTML_FlexyFramework::run('Noperm');  // noperm = loggedin -> need more perms / not.. try loggin in..
40         }
41           
42          
43         $live = 'master';
44         $release = 'github';
45          
46         $this->repo->debug = 1;
47         $ar = $this->repo->history("/", null, "rev",  "$release..$live");
48         //echo '<PRE>';print_R($ar);
49         
50         // need to get a 2 dimensional array of
51         // files along top, and commints down.
52         $cfiles = array();
53         $rows = array();
54         foreach($ar as $commit) {
55             $files = $commit->files;
56             $id = date("Y-m-d H:i", strtotime($commit->ctime));
57             if (!isset($row[$id])) { 
58                 $rows[$id] = $row= array(
59                     'commit' => $id,
60                     'desc' => $commit->changelog
61                 );
62             }
63             
64             foreach($files as $f=>$data) {
65                 $rows[$id][$f] = $commit->rev;
66                 $cfiles[$f] = isset($cfiles[$f]) ? $cfiles[$f] +1 : 1;
67             }
68             
69              
70         }
71         // this might result in alot of white boxes where you can
72         // let's see what it looks like..
73         echo '<PRE>';print_R($cfiles);
74         echo '<PRE>';print_R($rows);
75         die("done");
76         
77         
78         
79         
80     }
81     
82     
83     
84 }