php8
[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         $this->tree();
43         
44         
45         exit;
46         
47     }
48     function tree()
49     {
50         
51         $live = 'master';
52         $release = 'github';
53          
54         $this->repo->debug = 1;
55         $ar = $this->repo->history("/", null, "rev",  "$release..$live");
56         
57         // the point of this is to extract all the revisions, and group them.
58         
59         
60         
61         //echo '<PRE>';print_R($ar);
62         
63         // need to get a 2 dimensional array of
64         // files along top, and commints down.
65         $cfiles = array();
66         $rows = array();
67         foreach($ar as $commit) {
68             
69             $files = $commit->files;
70             $day = date("Y-m-d", strtotime($commit->ctime));
71             if (!isset($days[$day])) { 
72                 $days[$day] = array(
73                     'title' => $day,
74                     'rev' => $day,
75                     'children' => array()
76                 );
77             }
78             $time= date("H:i:s", strtotime($commit->ctime));
79             if (!isset($days[$day]['children'][$time])) { 
80                 $days[$day]['children'][$time] = array(
81                     'title' => $time,
82                     'rev' => $day . ' ' . $time,
83                     'commits' =>array(),
84                 );
85             }
86             $days[$day]['children'][$time]['children'][] = array(
87                 'title'=> $commit->changelog,
88                 'rev' => $commit->rev
89             );
90         }
91         // this might result in alot of white boxes where you can
92         // let's see what it looks like..
93         echo '<PRE>';print_R($days);
94         
95         
96         
97         
98         
99     }
100     
101     
102 }