$tc->ontable = 'mtrack_repos';
$tc->onid = $checker->repo->id;
$tc->rev= $rev;
+ $tc->branch = $ce->branch;
if ($tc->count()) { // if we have already tracked this..
return false;
}
$this->changedate = date('Y-m-d H:i:s', $ce->ctime);
$this->reason = $ce->changelog;
$this->person_id = $ce->changeby_id;
-
+ $this->branch = $ce->branch;
$this->rev = $rev;
$this->insert();
if ($obj->tableName() == 'mtrack_ticket') {
$obj = $obj->project();
+ } else {
+ $obj = $obj->branchObject($this->branch);
}
if ($obj) {
}
-
+ function branchObject($n)
+ {
+ // create or return branch dataobject
+ $b = DB_DataObject::factory('mtrack_repos_branch');
+ $b->repo_id = $this->id;
+ $b->name = $n;
+ if ($b->find(true)) {
+ return $b;
+ }
+ $b->insert();
+ return $b;
+
+ }
// these should really be phased out, and the Controlers use impl()-> directly..
function getBranches()
//print_r($last);exit;
$body = '';
-
+ $len = 0;
foreach($obj->summary as $file=>$who) {
$res = $this->impl()->diff($file, $last ? $last->rev : $first->rev, $last ? $first->rev : null);
//print_r($res);
//$lines = $this->parseDiff($res);
$lines = stream_get_contents($res);
+ $len += strlen($lines);
+ if ($len > 2000000) {
+ $lines = "Too large see repo";
+ }
if (preg_match('/\.map$/', $file)) {
$lines = "Changed";
//$this->impl()->debug=1;
//print_r(array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'));
- $res = $this->impl()->history('.', array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'), $object, $branch);
-
- // find the last rev the day before...
-
+ $res = $this->impl()->history('.', array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'), 'rev', '--all');
-
- $obj = $this->historyToSummary($res, $notify->act_start);
- if (!$obj) {
- // echo "History returned nothing";
- return true;
+ $branches = array();
+ foreach($res as $r) {
+ if (!preg_match('#^refs/heads/.*$#', $r->branch)) {
+ continue;
+ }
+ $br = preg_replace('#^refs/heads/.*$#', $r->branch, '');
+ $branches[$br] = 1;
+
+ }
+ $objs = array();
+ foreach($branches as $branch=>$one) {
+
+
+ $res = $this->impl()->history('.', array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'), $object, $branch);
+
+ // find the last rev the day before...
+
+
+
+ $obj = $this->historyToSummary($res, $notify->act_start);
+ if (!$obj) {
+ // echo "History returned nothing";
+ return true;
+ }
+ $obj->from_dt = $start;
+ $obj->to_dt = $end;
+ $obj->branch = $br;
+ //print_r($obj);exit;
+
+ $objs[] = $obj;
}
- $obj->from_dt = $start;
- $obj->to_dt = $end;
+ $ret = $rcpt->buildMail('repo_daily_changes', array('branches' => $obj));
- //print_r($obj);exit;
- $ret = $rcpt->buildMail('repo_daily_changes', $obj);
- //print_r($ret);exit;
return $ret;
--- /dev/null
+<?php
+/**
+ * Table Definition for mtrack_repos
+ */
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
+
+class Pman_MTrack_DataObjects_Mtrack_repos extends DB_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'mtrack_repos'; // table name
+ public $id; // int(11) not_null primary_key auto_increment
+ public $name; // string(64) not_null
+ public $repo_id; // string(16) not_null
+
+
+ function repo()
+ {
+ static $cache;
+ if (isset($cache[$this->repo_id])) {
+ return $cache[$this->repo_id];
+ }
+ $r = DB_DataObject::factory('mtrack_repo');
+ $r->get($this->repo_id);
+ $cache[$this->repo_id] = $r;
+ return $r;
+ }
+
+ function notifyENDOFDAYMAIL($rcpt, $last_sent_date, $notify, $force)
+ {
+ // fisrst use history to show a list of changes between the dates.
+ //die("building end of day mail");
+ // var_dump($notify->act_start );
+ $start = date('Y-m-d H:i:s', strtotime($notify->act_start . ' - 1 DAY'));
+ $end = date('Y-m-d H:i:s', strtotime($notify->act_start));
+
+
+ $object = 'branch';
+ $branch = $this->name;
+
+
+ //$this->impl()->debug=1;
+ //print_r(array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'));
+
+ $res = $this->repo()->impl()->history('.', array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'), $object, $branch);
+
+ // find the last rev the day before...
+
+
+
+ $obj = $this->repo()->historyToSummary($res, $notify->act_start);
+ if (!$obj) {
+ // echo "History returned nothing";
+ return true;
+ }
+ $obj->from_dt = $start;
+ $obj->to_dt = $end;
+ $obj->branch = $this->name;
+ //print_r($obj);exit;
+
+
+ $ret = $rcpt->buildMail('repo_daily_changes', $obj);
+
+ return $ret;
+
+
+
+
+
+
+ }
+
+
+}
+
\ No newline at end of file
-
--- Change tracking.. - may be moved up later???
-
-
-CREATE TABLE mtrack_change_audit (
- id int(11) NOT NULL AUTO_INCREMENT,
- change_id int(11) NOT NULL DEFAULT 0,
- fieldname varchar(128) DEFAULT '',
- action varchar(16) DEFAULT '',
- oldvalue text,
- value text,
- PRIMARY KEY(id)
-) ;
-ALTER TABLE mtrack_change_audit ADD COLUMN ticket_change_id int(11) NOT NULL DEFAULT 0;
-
-ALTER TABLE mtrack_change_audit ADD INDEX change_id_lookup (change_id);
-ALTER TABLE mtrack_change_audit ADD INDEX ticket_change_id_lookup (ticket_change_id);
-
-
-
-
-CREATE TABLE mtrack_change (
- id int(11) NOT NULL AUTO_INCREMENT,
- person_id int(11) DEFAULT 0,
- ontable varchar(128) DEFAULT '',
- onid int(11) NOT NULL DEFAULT 0,
- changedate datetime NOT NULL,
- rev varchar(32) NOT NULL DEFAULT '',
- reason text ,
- PRIMARY KEY (id)
-) ;
-
-ALTER TABLE mtrack_change ADD COLUMN rev varchar(64) NOT NULL DEFAULT '';
-
--- Caching??? - go back to file baseD?
-
-CREATE TABLE mtrack_clcache (
- id int(11) NOT NULL AUTO_INCREMENT,
- repo_id int(11) DEFAULT NULL,
- rev varchar(128) DEFAULT NULL,
- sobject longtext,
- PRIMARY KEY (id)
-) ;
+-- this stuff is not used anymore...
-- Table structure for table components_by_project
-
+-- ?? not used?
CREATE TABLE mtrack_project_reference (
id int(11) NOT NULL AUTO_INCREMENT,
project_id int(11) NOT NULL,
--- Table structure for table milestones
--- change/update etc are references to mtrack_changes
-CREATE TABLE mtrack_milestone (
- id int(11) NOT NULL AUTO_INCREMENT,
- name varchar(128) DEFAULT NULL,
- description text,
- startdate datetime DEFAULT NULL,
- duedate datetime DEFAULT NULL,
- completed datetime DEFAULT NULL,
- deleted int(11) NOT NULL DEFAULT '0',
- created int(11) NOT NULL,
- updated int(11) NOT NULL,
- project_id int(11) DEFAULT 0,
- PRIMARY KEY (id)
-);
-ALTER TABLE mtrack_milestone CHANGE column pmid project_id int (11) DEFAULT 0;
-ALTER TABLE mtrack_milestone CHANGE column completed completed int (11) NOT NULL DEFAULT 0;
-ALTER TABLE mtrack_milestone ADD column on_hold int (2) NOT NULL DEFAULT 0;
-- reports??? - may change quite a bit later?
-- change/update etc are references to mtrack_changes
-
+-- not used?
CREATE TABLE mtrack_report (
id int(11) NOT NULL AUTO_INCREMENT,
summary varchar(128) NOT NULL,
-- Table structure for table repos
-CREATE TABLE mtrack_repos (
- id int(11) NOT NULL AUTO_INCREMENT,
- shortname varchar(64) NOT NULL DEFAULT '',
- scmtype varchar(16) NOT NULL DEFAULT '',
- repopath varchar(255) NOT NULL DEFAULT '',
- browserurl varchar(255) DEFAULT NULL DEFAULT '',
- browsertype varchar(255) DEFAULT NULL DEFAULT '',
- description text,
- serverurl varchar(255) DEFAULT NULL DEFAULT '',
- parent varchar(255) NOT NULL DEFAULT '',
- clonedfrom int(11) DEFAULT NULL,
- PRIMARY KEY (id)
-) ;
-ALTER TABLE mtrack_repos ADD COLUMN project_id INT(11) DEFAULT 0;
-ALTER TABLE mtrack_repos ADD INDEX plookup(project_id);
-
-
+-- not used?
CREATE TABLE mtrack_snippet (
id int(11) NOT NULL AUTO_INCREMENT,
created int(11) NOT NULL DEFAULT 0,
-- Table structure for table ticket_changeset_hashes
-#CREATE TABLE ticket_changeset_hashes (
-#tid char(32) NOT NULL,
-# hash varchar(128) NOT NULL DEFAULT '',
-# PRIMARY KEY (tid,hash)
-#) ;
+-- CREATE TABLE ticket_changeset_hashes (
+-- tid char(32) NOT NULL,
+-- hash varchar(128) NOT NULL DEFAULT '',
+-- PRIMARY KEY (tid,hash)
+--) ;
-- Table structure for table ticket_components
-
+-- not used
CREATE TABLE mtrack_ticket_reference (
id int(11) NOT NULL AUTO_INCREMENT,
ticket_id int(11) NOT NULL,
--- Table structure for table tickets
-
-CREATE TABLE mtrack_ticket (
- id int(11) NOT NULL AUTO_INCREMENT,
- project_id int(11) NOT NULL DEFAULT 0,
- summary longtext,
- description longtext,
- changelog longtext,
- created int(11) NOT NULL DEFAULT 0,
- updated int(11) NOT NULL DEFAULT 0,
- owner_id int(11) NOT NULL DEFAULT 0,
- priority_id int(11) NOT NULL DEFAULT 0,
- severity_id int(11) NOT NULL DEFAULT 0,
- classification_id int(11) NOT NULL DEFAULT 0,
- resolution_id int(11) NOT NULL DEFAULT 0,
- cc text,
- status int(11) NOT NULL DEFAULT 0,
- estimated double DEFAULT NULL,
- spent double DEFAULT NULL,
- x_fieldname text,
- PRIMARY KEY (id)
-) ;
-
-ALTER TABLE mtrack_ticket ADD COLUMN project_id int(11) NOT NULL DEFAULT 0;
-ALTER TABLE mtrack_ticket ADD COLUMN developer_id int(11) NOT NULL DEFAULT 0;
-ALTER TABLE mtrack_ticket ADD COLUMN milestone_id int(11) NOT NULL DEFAULT 0;
-ALTER TABLE mtrack_ticket ADD COLUMN act_now int(11) NOT NULL DEFAULT 0;
-ALTER TABLE mtrack_ticket ADD COLUMN seqid int(11) NOT NULL DEFAULT 0;
-
-
-
-CREATE TABLE mtrack_wiki (
- id int(11) NOT NULL AUTO_INCREMENT,
- project_id int(11) NOT NULL DEFAULT 0,
- path varchar(128) NOT NULL DEFAULT '',
- wikidata longtext NOT NULL,
- created_id int(11) NOT NULL DEFAULT 0,
- updated_id int(11) NOT NULL DEFAULT 0,
- is_protected int(2) NOT NULL COMMENT 'if so team only',
- is_protected_company int(2) NOT NULL DEFAULT 0,
- protected_group text NOT NULL,
- PRIMARY KEY (id),
- INDEX lookup(project_id, path)
-);
-
-CREATE TABLE mtrack_desktop_activity (
+-- not used?
+ CREATE TABLE mtrack_desktop_activity (
id int(11) NOT NULL AUTO_INCREMENT,
cmd_id int(11) NOT NULL,
title_id int(11) NOT NULL,
) ;
-ALTER TABLE cash_invoice_entry ADD COLUMN `ticket_id` int(11) NOT NULL DEFAULT 0;
-
-CREATE TABLE mtrack_jira (
- id INT NOT NULL AUTO_INCREMENT ,
- project_id INT(11) NOT NULL DEFAULT 0 ,
- jira_url TEXT NOT NULL ,
- username VARCHAR(128) NOT NULL ,
- passwd VARCHAR(128) NOT NULL ,
- PRIMARY KEY (id)
-);
-
-
-CREATE TABLE mtrack_jira_object (
- id INT NOT NULL AUTO_INCREMENT ,
- on_table VARCHAR(64) NOT NULL ,
- on_id INT NOT NULL DEFAULT 0 ,
- jira_ref VARCHAR(64) NOT NULL ,
- PRIMARY KEY (id)
- );
-
- alter table mtrack_jira_object add column jira_key VARCHAR(64) NOT NULL;
--- /dev/null
+ALTER TABLE cash_invoice_entry ADD COLUMN `ticket_id` int(11) NOT NULL DEFAULT 0;
--- /dev/null
+
+CREATE TABLE mtrack_change (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ person_id int(11) DEFAULT 0,
+ ontable varchar(128) DEFAULT '',
+ onid int(11) NOT NULL DEFAULT 0,
+ changedate datetime NOT NULL,
+ rev varchar(32) NOT NULL DEFAULT '',
+ reason text ,
+ PRIMARY KEY (id)
+) ;
+
+ALTER TABLE mtrack_change ADD COLUMN rev varchar(64) NOT NULL DEFAULT '';
+ALTER TABLE mtrack_change ADD COLUMN branch varchar(64) NOT NULL DEFAULT '';
--- /dev/null
+
+
+CREATE TABLE mtrack_change_audit (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ change_id int(11) NOT NULL DEFAULT 0,
+ fieldname varchar(128) DEFAULT '',
+ action varchar(16) DEFAULT '',
+ oldvalue text,
+ value text,
+ PRIMARY KEY(id)
+) ;
+ALTER TABLE mtrack_change_audit ADD COLUMN ticket_change_id int(11) NOT NULL DEFAULT 0;
+
+ALTER TABLE mtrack_change_audit ADD INDEX change_id_lookup (change_id);
+ALTER TABLE mtrack_change_audit ADD INDEX ticket_change_id_lookup (ticket_change_id);
--- /dev/null
+-- Caching??? - go back to file baseD?
+
+CREATE TABLE mtrack_clcache (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ repo_id int(11) DEFAULT NULL,
+ rev varchar(128) DEFAULT NULL,
+ sobject longtext,
+ PRIMARY KEY (id)
+) ;
+
--- /dev/null
+
+CREATE TABLE mtrack_jira (
+ id INT NOT NULL AUTO_INCREMENT ,
+ project_id INT(11) NOT NULL DEFAULT 0 ,
+ jira_url TEXT NOT NULL ,
+ username VARCHAR(128) NOT NULL ,
+ passwd VARCHAR(128) NOT NULL ,
+ PRIMARY KEY (id)
+);
\ No newline at end of file
--- /dev/null
+CREATE TABLE mtrack_jira_object (
+ id INT NOT NULL AUTO_INCREMENT ,
+ on_table VARCHAR(64) NOT NULL ,
+ on_id INT NOT NULL DEFAULT 0 ,
+ jira_ref VARCHAR(64) NOT NULL ,
+ PRIMARY KEY (id)
+ );
+
+ alter table mtrack_jira_object add column jira_key VARCHAR(64) NOT NULL;
+
--- /dev/null
+-- Table structure for table milestones
+-- change/update etc are references to mtrack_changes
+CREATE TABLE mtrack_milestone (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ name varchar(128) DEFAULT NULL,
+ description text,
+ startdate datetime DEFAULT NULL,
+ duedate datetime DEFAULT NULL,
+ completed datetime DEFAULT NULL,
+ deleted int(11) NOT NULL DEFAULT '0',
+ created int(11) NOT NULL,
+ updated int(11) NOT NULL,
+ project_id int(11) DEFAULT 0,
+ PRIMARY KEY (id)
+);
+
+ALTER TABLE mtrack_milestone CHANGE column pmid project_id int (11) DEFAULT 0;
+ALTER TABLE mtrack_milestone CHANGE column completed completed int (11) NOT NULL DEFAULT 0;
+ALTER TABLE mtrack_milestone ADD column on_hold int (2) NOT NULL DEFAULT 0;
\ No newline at end of file
--- /dev/null
+CREATE TABLE mtrack_repos (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ shortname varchar(64) NOT NULL DEFAULT '',
+ scmtype varchar(16) NOT NULL DEFAULT '',
+ repopath varchar(255) NOT NULL DEFAULT '',
+ browserurl varchar(255) DEFAULT NULL DEFAULT '',
+ browsertype varchar(255) DEFAULT NULL DEFAULT '',
+ description text,
+ serverurl varchar(255) DEFAULT NULL DEFAULT '',
+ parent varchar(255) NOT NULL DEFAULT '',
+ clonedfrom int(11) DEFAULT NULL,
+ PRIMARY KEY (id)
+) ;
+ALTER TABLE mtrack_repos ADD COLUMN project_id INT(11) DEFAULT 0;
+ALTER TABLE mtrack_repos ADD INDEX plookup(project_id);
+
+
\ No newline at end of file
--- /dev/null
+CREATE TABLE mtrack_repos_branch (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ name varchar(64) NOT NULL DEFAULT '',
+ repo_id INT(11) NOT NULL DEFAULT 0,
+ PRIMARY KEY (id)
+) ;
+ALTER TABLE mtrack_repos_branch ADD INDEX plookup(repo_id,name);
+
+
\ No newline at end of file
--- /dev/null
+
+-- Table structure for table tickets
+
+CREATE TABLE mtrack_ticket (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ project_id int(11) NOT NULL DEFAULT 0,
+ summary longtext,
+ description longtext,
+ changelog longtext,
+ created int(11) NOT NULL DEFAULT 0,
+ updated int(11) NOT NULL DEFAULT 0,
+ owner_id int(11) NOT NULL DEFAULT 0,
+ priority_id int(11) NOT NULL DEFAULT 0,
+ severity_id int(11) NOT NULL DEFAULT 0,
+ classification_id int(11) NOT NULL DEFAULT 0,
+ resolution_id int(11) NOT NULL DEFAULT 0,
+ cc text,
+ status int(11) NOT NULL DEFAULT 0,
+ estimated double DEFAULT NULL,
+ spent double DEFAULT NULL,
+ x_fieldname text,
+ PRIMARY KEY (id)
+) ;
+
+ALTER TABLE mtrack_ticket ADD COLUMN project_id int(11) NOT NULL DEFAULT 0;
+ALTER TABLE mtrack_ticket ADD COLUMN developer_id int(11) NOT NULL DEFAULT 0;
+ALTER TABLE mtrack_ticket ADD COLUMN milestone_id int(11) NOT NULL DEFAULT 0;
+ALTER TABLE mtrack_ticket ADD COLUMN act_now int(11) NOT NULL DEFAULT 0;
+ALTER TABLE mtrack_ticket ADD COLUMN seqid int(11) NOT NULL DEFAULT 0;
+
--- /dev/null
+
+CREATE TABLE mtrack_wiki (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ project_id int(11) NOT NULL DEFAULT 0,
+ path varchar(128) NOT NULL DEFAULT '',
+ wikidata longtext NOT NULL,
+ created_id int(11) NOT NULL DEFAULT 0,
+ updated_id int(11) NOT NULL DEFAULT 0,
+ is_protected int(2) NOT NULL COMMENT 'if so team only',
+ is_protected_company int(2) NOT NULL DEFAULT 0,
+ protected_group text NOT NULL,
+ PRIMARY KEY (id),
+ INDEX lookup(project_id, path)
+);
\ No newline at end of file