diff --git a/codepot/etc/codepot.sql b/codepot/etc/codepot.sql index ab97d2e5..9d72a071 100644 --- a/codepot/etc/codepot.sql +++ b/codepot/etc/codepot.sql @@ -75,9 +75,11 @@ CREATE TABLE file ( CREATE TABLE log ( id BIGINT PRIMARY KEY AUTO_INCREMENT, - type VARCHAR(16) NOT NULL, projectid VARCHAR(32) NOT NULL, + type VARCHAR(16) NOT NULL, + action VARCHAR(16) NOT NULL, + userid VARCHAR(32) NOT NULL, message TEXT NOT NULL, createdon DATETIME NOT NULL, - INDEX timed_type_project (createdon, type, projectid) + INDEX timed_project_type_action (createdon, projectid, type, action) ) charset=utf8 engine=InnoDB; diff --git a/codepot/etc/post-commit b/codepot/etc/post-commit index 2b07be21..c95bf1e1 100755 --- a/codepot/etc/post-commit +++ b/codepot/etc/post-commit @@ -4,5 +4,5 @@ REPOBASE="`basename "${1}"`" REV="${2}" # does not care if logging has failed. -wget -q -O- "%API%/logSvnCommit/${REPOBASE}/${REV}" 2>/dev/null +wget -q -O- "%API%/logCodeCommit/svn/${REPOBASE}/${REV}" 2>/dev/null exit 0 diff --git a/codepot/src/codepot/controllers/api.php b/codepot/src/codepot/controllers/api.php index 1b0a52e6..a1b49600 100644 --- a/codepot/src/codepot/controllers/api.php +++ b/codepot/src/codepot/controllers/api.php @@ -25,13 +25,13 @@ class API extends Controller print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES'; } - function logSvnCommit ($repo, $rev) + function logCodeCommit ($type, $repo, $rev) { if (!isset($repo) || !isset($rev)) return; // TODO: access control - may allow localhost only $this->load->model ('LogModel', 'logs'); - $this->logs->writeSvnCommit ($repo, $rev); + $this->logs->writeCodeCommit ($type, $repo, $rev, ''); } } diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index cc72dd3d..465f6601 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -44,9 +44,9 @@ class Project extends Controller } else { - $svn_commits = $this->logs->getSvnCommits ( + $log_entries = $this->logs->getEntries ( 0, CODEPOT_MAX_SVN_COMMITS_IN_PROJECT, $projectid); - if ($svn_commits === FALSE) + if ($log_entries === FALSE) { $data['message'] = 'DATABASE ERROR'; $this->load->view ($this->VIEW_ERROR, $data); @@ -54,7 +54,7 @@ class Project extends Controller else { $data['project'] = $project; - $data['svn_commits'] = $svn_commits; + $data['log_entries'] = $log_entries; $this->load->view ($this->VIEW_HOME, $data); } } diff --git a/codepot/src/codepot/controllers/user.php b/codepot/src/codepot/controllers/user.php index 31376086..ec1a8dd5 100644 --- a/codepot/src/codepot/controllers/user.php +++ b/codepot/src/codepot/controllers/user.php @@ -54,8 +54,8 @@ class User extends Controller return; } - $svn_commits = $this->logs->getSvnCommits (0, CODEPOT_MAX_SVN_COMMITS); - if ($svn_commits === FALSE) + $log_entries = $this->logs->getEntries (0, CODEPOT_MAX_SVN_COMMITS); + if ($log_entries === FALSE) { $data['login'] = $login; $data['message'] = 'DATABASE ERROR'; @@ -65,7 +65,7 @@ class User extends Controller $data['login'] = $login; $data['latest_projects'] = $latest_projects; - $data['svn_commits'] = $svn_commits; + $data['log_entries'] = $log_entries; $data['site'] = $site; //$data['user_name'] = ''; //$data['user_pass'] = ''; @@ -79,8 +79,8 @@ class User extends Controller $this->load->library ('pagination'); $this->load->model ('LogModel', 'logs'); - $num_svn_commits = $this->logs->getNumSvnCommits (); - if ($num_svn_commits === FALSE) + $num_log_entries = $this->logs->getNumEntries (); + if ($num_log_entries === FALSE) { $data['login'] = $login; $data['message'] = 'DATABASE ERROR'; @@ -89,11 +89,11 @@ class User extends Controller } $pagecfg['base_url'] = site_url() . '/user/sitelog/'; - $pagecfg['total_rows'] = $num_svn_commits; + $pagecfg['total_rows'] = $num_log_entries; $pagecfg['per_page'] = CODEPOT_MAX_SITE_LOGS_PER_PAGE; - $svn_commits = $this->logs->getSvnCommits ($offset, $pagecfg['per_page']); - if ($svn_commits === FALSE) + $log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page']); + if ($log_entries === FALSE) { $data['login'] = $login; $data['message'] = 'DATABASE ERROR'; @@ -105,7 +105,7 @@ class User extends Controller $this->pagination->initialize ($pagecfg); $data['login'] = $login; - $data['sitelogs'] = $svn_commits; + $data['log_entries'] = $log_entries; $data['page_links'] = $this->pagination->create_links (); $this->load->view ($this->VIEW_SITELOG, $data); diff --git a/codepot/src/codepot/models/logmodel.php b/codepot/src/codepot/models/logmodel.php index bc786d4a..3f4e9021 100644 --- a/codepot/src/codepot/models/logmodel.php +++ b/codepot/src/codepot/models/logmodel.php @@ -8,11 +8,12 @@ class LogModel extends Model $this->load->database (); } - function getNumSvnCommits ($projectid = '') + function getNumEntries ($projectid = '') { $this->db->trans_start (); - $this->db->where ('type', 'svn-commit'); + //$this->db->where ('type', 'code'); + //$this->db->where ('action', 'commit'); if ($projectid != '') $this->db->where ('projectid', $projectid); $num = $this->db->count_all ('log'); @@ -22,11 +23,12 @@ class LogModel extends Model return $num; } - function getSvnCommits ($offset, $limit, $projectid = '') + function getEntries ($offset, $limit, $projectid = '') { $this->db->trans_start (); - $this->db->where ('type', 'svn-commit'); + //$this->db->where ('type', 'code'); + //$this->db->where ('action', 'commit'); if ($projectid != '') $this->db->where ('projectid', $projectid); $this->db->order_by ('createdon', 'desc'); $query = $this->db->get ('log', $limit, $offset); @@ -39,43 +41,49 @@ class LogModel extends Model $commits = array (); foreach ($result as $row) { - list($repo,$rev) = split('[,]', $row->message); + list($type,$repo,$rev) = split('[,]', $row->message); /* $row->project must be equal to $repo */ - $commits[$count]['time'] = $row->createdon; + $commits[$count]['createdon'] = $row->createdon; $commits[$count]['type'] = $row->type; + $commits[$count]['action'] = $row->action; $commits[$count]['projectid'] = $row->projectid; + $commits[$count]['userid'] = $row->userid; - $commits[$count]['svn_repo'] = $repo; - $commits[$count]['svn_rev'] = $rev; + $tmp['type'] = $type; + $tmp['repo'] = $repo; + $tmp['rev'] = $rev; $log = @svn_log ( 'file:///'.CODEPOT_SVNREPO_DIR."/{$repo}", $rev, $rev, 1,SVN_DISCOVER_CHANGED_PATHS); if ($log === FALSE || count($log) < 1) { - $commits[$count]['svn_author'] = ''; - $commits[$count]['svn_message'] = ''; - $commits[$count]['svn_time'] = ''; + $tmp['time'] = ''; + $tmp['author'] = ''; + $tmp['message'] = ''; } else { - $commits[$count]['svn_author'] = $log[0]['author']; - $commits[$count]['svn_message'] = $log[0]['msg']; - $commits[$count]['svn_time'] = $log[0]['date']; + $tmp['time'] = $log[0]['date']; + $tmp['author'] = $log[0]['author']; + $tmp['message'] = $log[0]['msg']; } + $commits[$count][$row->type.'-'.$row->action] = $tmp; $count++; } return $commits; } - function writeSvnCommit ($repo, $rev) + function writeCodecommit ($type, $repo, $rev, $userid) { - $log->type = 'svn-commit'; + $log->type = 'code'; + $log->action = 'commit'; $log->projectid = $repo; - $log->message = "{$repo},{$rev}"; + $log->userid = $userid; + $log->message = "{$type},{$repo},{$rev}"; $this->write ($log); } @@ -84,6 +92,7 @@ class LogModel extends Model $this->db->trans_begin (); $this->db->set ('type', $log->type); + $this->db->set ('action', $log->action); $this->db->set ('projectid', $log->projectid); $this->db->set ('message', $log->message); $this->db->set ('createdon', date('Y-m-d H:i:s')); diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 2c562dbf..6bf1ff84 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -43,8 +43,8 @@ class SubversionModel extends Model if ($list === FALSE) return FALSE; $log = @svn_log ($url, - $fileinfo['created_rev'], - $fileinfo['created_rev'], + $info[0]['revision'], + $info[0]['revision'], 1, SVN_DISCOVER_CHANGED_PATHS); if ($log === FALSE) return FALSE; diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index ab47f818..d0dfb8c5 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -84,35 +84,39 @@ $this->load->view (
-id}", $this->lang->line('Code changes')) ?> +id}", $this->lang->line('Change log')) ?>
- +
converter->AsciiToHex ('.'); - foreach ($svn_commits as $commit) + foreach ($log_entries as $log) { - print ''; - print ''; + if ($log['type'] == 'code' && $log['action'] == 'commit') + { + $x = $log['code-commit']; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + } } ?>
'; - print substr($commit['svn_time'], 0, 10); - print ''; - print anchor ( - "/source/revision/{$commit['svn_repo']}/{$xdot}/{$commit['svn_rev']}", - $commit['svn_rev']); - print '
'; + print substr($x['time'], 0, 10); + print ''; - print htmlspecialchars ($commit['svn_author']); - print '
'; + print anchor ( + "/source/revision/{$x['repo']}/{$xdot}/{$x['rev']}", + $x['rev']); + print ''; + print htmlspecialchars ($x['author']); + print '
'; - $sm = strtok (trim ($commit['svn_message']), "\r\n"); - print htmlspecialchars ($sm); - print '
'; + $sm = strtok (trim ($x['message']), "\r\n"); + print htmlspecialchars ($sm); + print '
diff --git a/codepot/src/codepot/views/source_folder.php b/codepot/src/codepot/views/source_folder.php index 0a975d8e..b6f61d90 100644 --- a/codepot/src/codepot/views/source_folder.php +++ b/codepot/src/codepot/views/source_folder.php @@ -30,15 +30,13 @@ $this->load->view ( -= 0): ?> -