58fbe4c6f07d1c53c8b3fd91b7dea26ed3b937e7
Author: gwoo
Date: 2009-07-30 15:36:41 -0700
diff --git a/config/routes.php b/config/routes.php
index 04b804d..31c2ea0 100755
--- a/config/routes.php
+++ b/config/routes.php
@@ -46,7 +46,7 @@
);
Router::connect('/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects',
- 'action' => 'branches|history|logs|view|start|add|edit|modify|delete|remove|activate|forgotten|verify|change|login|account|logout|forks',
+ 'action' => 'branches|branch|logs|view|start|add|edit|modify|delete|remove|activate|forgotten|verify|change|login|account|logout|forks',
'project' => false)
);
Router::connect('/:controller/*', array(), array(
@@ -60,7 +60,7 @@
Router::connect('/forks/:fork/:project/:controller', array('action' => 'index'), array('action' => 'index'));
Router::connect('/forks/:fork/:project/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects|repo',
- 'action' => 'branches|history|logs|fast_forward|view|add|edit|modify|delete|remove|parent')
+ 'action' => 'branches|branch|logs|fast_forward|view|add|edit|modify|delete|remove|parent')
);
Router::connect('/forks/:fork/:project/:controller/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects',
@@ -73,7 +73,7 @@
Router::connect('/:project/:controller', array('action' => 'index'), array('action' => 'index'));
Router::connect('/:project/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects|repo',
- 'action' => 'branches|history|logs|merge|view|add|edit|modify|delete|remove|forks')
+ 'action' => 'branches|branch|logs|merge|view|add|edit|modify|delete|remove|forks')
);
Router::connect('/:project/:controller/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|timeline|versions|users|projects',
diff --git a/controllers/commits_controller.php b/controllers/commits_controller.php
index a8eff05..0f1314c 100755
--- a/controllers/commits_controller.php
+++ b/controllers/commits_controller.php
@@ -36,8 +36,9 @@ class CommitsController extends AppController {
}
function view($revision = null) {
+ $branches = $this->Project->Repo->find('branches');
$commit = $this->Commit->findByRevision($revision);
- $this->set('commit', $commit);
+ $this->set(compact('commit', 'branches'));
}
function logs($commits = null) {
@@ -47,16 +48,11 @@ class CommitsController extends AppController {
$this->set(compact('commits', 'args', 'current'));
}
- function history() {
+ function branch() {
+ $branches = $this->Project->Repo->find('branches');
$args = func_get_args();
- if (empty($args)) {
- $this->redirect($this->referer());
- }
-
if ($this->Project->Repo->type == 'git') {
- if ($args[0] == 'branches') {
- array_shift($args);
- } else {
+ if (empty($args)) {
$this->Project->Repo->branch('master', true);
}
}
@@ -66,7 +62,7 @@ class CommitsController extends AppController {
$commits = $this->paginate($this->Project->Repo, array('path' => $path));
- $this->set(compact('commits', 'args', 'current'));
+ $this->set(compact('commits', 'branches', 'args', 'current'));
}
function remove($id = null) {
diff --git a/controllers/source_controller.php b/controllers/source_controller.php
index 7329837..52bf68b 100644
--- a/controllers/source_controller.php
+++ b/controllers/source_controller.php
@@ -44,11 +44,14 @@ class SourceController extends AppController {
$args = func_get_args();
if ($this->Project->Repo->type == 'git') {
$this->Project->Repo->branch('master', true);
+ } else {
+ $this->Project->Repo->update();
}
+
list($args, $path, $current) = $this->Source->initialize($this->Project->Repo, $args);
$data = $this->Source->read($path);
-
+
$this->pageTitle = $current;
if (!empty($args)) {
$this->pageTitle = join('/', $args) . '/' . $current;
diff --git a/models/commit.php b/models/commit.php
index 9905e0c..0c9cc5f 100644
--- a/models/commit.php
+++ b/models/commit.php
@@ -64,6 +64,8 @@ class Commit extends AppModel {
}
function afterSave($created) {
+ $this->log($this->data);
+
if ($created && $this->addToTimeline) {
$Timeline = ClassRegistry::init('Timeline');
$timeline = array('Timeline' => array(
@@ -74,7 +76,6 @@ class Commit extends AppModel {
'event' => $this->data['Commit']['event'],
'data' => $this->data['Commit']['data']
));
-
$Timeline->create($timeline);
$Timeline->save();
}
@@ -94,7 +95,11 @@ class Commit extends AppModel {
function isUnique($data, $options = array()) {
if (!empty($data['revision'])) {
$this->recursive = -1;
- if ($id = $this->field('id', array('revision' => $data['revision']))) {
+ $project_id = $this->Project->id;
+ if (!empty($this->data['Commit']['project_id'])) {
+ $project_id = $this->data['Commit']['project_id'];
+ }
+ if ($id = $this->field('id', array('revision' => $data['revision'], 'project_id' => $project_id))) {
if ($this->id && $this->id == $id) {
return true;
}
diff --git a/plugins/repo/models/git.php b/plugins/repo/models/git.php
index 6f1911b..2f92b0b 100644
--- a/plugins/repo/models/git.php
+++ b/plugins/repo/models/git.php
@@ -88,7 +88,7 @@ class Git extends Repo {
$this->commit("Initial Project Commit");
$this->push();
}
- $this->log($this->debug, LOG_DEBUG);
+ //$this->log($this->debug, LOG_DEBUG);
if (is_dir($path) && is_dir($this->working)) {
return true;
@@ -313,6 +313,9 @@ class Git extends Repo {
**/
function find($type = 'all', $options = array()) {
if ($type == 'branches') {
+ if (empty($this->branch)) {
+ $this->branch('master', true);
+ }
$this->cd();
$result = $this->run('branch -a', null, 'capture');
$branches = array();
diff --git a/vendors/shells/git_shell.php b/vendors/shells/git_shell.php
index 697324a..8274b05 100644
--- a/vendors/shells/git_shell.php
+++ b/vendors/shells/git_shell.php
@@ -92,7 +92,7 @@ class GitShellShell extends Shell {
$fork = @$this->args[1];
$this->args[] = 'git_shell';
- $this->log($this->args, LOG_INFO);
+ //$this->log($this->args, LOG_INFO);
if ($this->Project->initialize(compact('project', 'fork')) === false || $this->Project->current['url'] !== $project) {
$this->err('Invalid Project');
diff --git a/vendors/shells/svn_shell.php b/vendors/shells/svn_shell.php
index 39b9ff6..7519b0c 100644
--- a/vendors/shells/svn_shell.php
+++ b/vendors/shells/svn_shell.php
@@ -41,8 +41,8 @@ class SvnShellShell extends Shell {
}
$this->args[] = 'svn_shell';
- $this->log($this->args, LOG_DEBUG);
- $this->log($this->params, LOG_DEBUG);
+ //$this->log($this->args, LOG_DEBUG);
+ //$this->log($this->params, LOG_DEBUG);
//$this->Project->permit($this->params['user']);
diff --git a/views/commits/branch.ctp b/views/commits/branch.ctp
new file mode 100755
index 0000000..13b98d0
--- /dev/null
+++ b/views/commits/branch.ctp
@@ -0,0 +1,81 @@
+<?php
+$script = '
+$(document).ready(function(){
+ $(".message").each(function () {
+ $(this).html(converter.makeHtml(jQuery.trim($(this).text())))
+ });
+});
+';
+$javascript->codeBlock($script, array('inline' => false));
+?>
+<div class="page-navigation">
+ Branches
+ <?php
+ foreach((array)$branches as $branch) :
+ echo ' | ' . $html->link($branch, $chaw->url((array)$CurrentProject, array(
+ 'controller' => 'commits', 'action' => 'branch', $branch
+ )));
+ endforeach;
+ ?>
+
+</div>
+
+<h2>
+ <?php __('Commits for') ?>
+
+ <?php
+ $title = null;
+ if (!empty($CurrentProject->fork)) {
+ $title = "forks / {$CurrentProject->fork} / ";
+ }
+ $title .= $CurrentProject->url;
+ echo $html->link($title, array('controller' => 'source', 'action' => 'index'));
+ ?>
+ <?php
+ $path = '/';
+ foreach ((array)$args as $part):
+ $path .= $part . '/';
+ echo '/' . $html->link(' ' . $part . ' ', array('controller' => 'source', 'action' => 'index', $path));
+ endforeach;
+ echo '/ ' . $html->link($current, array('controller' => 'source', 'action' => 'index', $path, $current));
+ ?>
+</h2>
+
+<div class="commits history">
+
+ <?php $i = 0; foreach ((array)$commits as $commit): $zebra = ($i++ % 2) ? ' zebra' : null?>
+
+ <div class="commit <?php echo $zebra?>">
+ <strong>
+ <?php echo $chaw->commit($commit['Repo']['revision'], (array)$CurrentProject);?>
+ </strong>
+
+ <div class="right">
+ <p>
+ <strong><?php __('Author') ?>:</strong> <?php echo $commit['Repo']['author'];?>
+ </p>
+
+ <p>
+ <strong><?php __('Date') ?>:</strong> <?php echo $commit['Repo']['commit_date'];?>
+ </p>
+ </div>
+
+ <p class="message">
+ <?php echo $commit['Repo']['message'];?>
+ </p>
+
+ <div class="clear"><!----></div>
+
+ </div>
+
+ <?php endforeach;?>
+
+</div>
+<div class="paging">
+<?php
+ $paginator->options(array('url' => $this->passedArgs));
+ echo $paginator->prev();
+ echo $paginator->numbers(array('before' => ' | ', 'after' => ' | '));
+ echo $paginator->next();
+?>
+</div>
\ No newline at end of file
diff --git a/views/commits/history.ctp b/views/commits/history.ctp
deleted file mode 100755
index 678af8c..0000000
--- a/views/commits/history.ctp
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-$script = '
-$(document).ready(function(){
- $(".message").each(function () {
- $(this).html(converter.makeHtml(jQuery.trim($(this).text())))
- });
-});
-';
-$javascript->codeBlock($script, array('inline' => false));
-?>
-
-<div class="commits history">
- <h2>
- <?php __('History') ?>
- </h2>
- <h3>
- <?php
- $title = null;
- if (!empty($CurrentProject->fork)) {
- $title = "forks / {$CurrentProject->fork} / ";
- }
- $title .= $CurrentProject->url;
- echo $html->link($title, array('controller' => 'source', 'action' => 'index'));
- ?>
- <?php
- $path = '/';
- foreach ((array)$args as $part):
- $path .= $part . '/';
- echo '/' . $html->link(' ' . $part . ' ', array('controller' => 'source', 'action' => 'index', $path));
- endforeach;
- echo '/ ' . $html->link($current, array('controller' => 'source', 'action' => 'index', $path, $current));
- ?>
- </h3>
- <?php foreach ((array)$commits as $commit):?>
-
- <div class="commit">
-
- <h4>
- <?php echo $chaw->commit($commit['Repo']['revision']);?>
- </h4>
-
- <p>
- <strong><?php __('Author') ?>:</strong> <?php echo $commit['Repo']['author'];?>
- </p>
-
- <p>
- <strong><?php __('Date') ?>:</strong> <?php echo $commit['Repo']['commit_date'];?>
- </p>
-
- <p class="message">
- <?php echo $commit['Repo']['message'];?>
- </p>
-
- </div>
-
- <?php endforeach;?>
-
-</div>
-<div class="paging">
-<?php
- $paginator->options(array('url' => $this->passedArgs));
- echo $paginator->prev();
- echo $paginator->numbers(array('before' => ' | ', 'after' => ' | '));
- echo $paginator->next();
-?>
-</div>
\ No newline at end of file
diff --git a/views/commits/view.ctp b/views/commits/view.ctp
index a703223..ac8ad84 100755
--- a/views/commits/view.ctp
+++ b/views/commits/view.ctp
@@ -11,6 +11,14 @@ $javascript->codeBlock($script, array('inline' => false));
?>
<div class="page-navigation">
<?php echo $html->link(__('All Commits',true), array('controller' => 'commits', 'action' => 'index'));?>
+ <?php
+ foreach((array)$branches as $branch) :
+ echo ' | ' .$html->link($branch, $chaw->url((array)$CurrentProject, array(
+ 'controller' => 'commits', 'action' => 'branch', $branch
+ )));
+ endforeach;
+ ?>
+
</div>
<h2>
diff --git a/views/elements/project_details.ctp b/views/elements/project_details.ctp
index 0ae73ef..3c5cb73 100755
--- a/views/elements/project_details.ctp
+++ b/views/elements/project_details.ctp
@@ -1,6 +1,9 @@
<?php if (!empty($CurrentProject)):?>
<div class="project-details">
<?php
+ if(empty($branch)) {
+ $branch = null;
+ }
if (empty($CurrentProject->approved)) {
echo $html->tag('span', __('Awaiting Approval',true), array('class' => 'inactive'));
}
@@ -52,15 +55,27 @@
endif;
echo $html->tag('span', $link);
endif;
- if (!empty($this->params['isAdmin']) && !empty($branch)):
+ if (!empty($this->params['isAdmin'])):
echo $html->tag('span', $html->link(__('remove branch',true), array(
'admin' => false,
'controller' => 'source', 'action' => 'delete', $branch
), array('class' => 'detail')));
endif;
+
+ echo $html->tag('span', $html->link(__('view commits',true), $chaw->url((array)$CurrentProject, array(
+ 'admin' => false,
+ 'controller' => 'commits', 'action' => 'branch', $branch
+ )), array('class' => 'history')));
+
else:
echo '<strong>svn checkout</strong> ';
echo "{$CurrentProject->remote->svn}/$remote{$CurrentProject->url}";
+
+ echo $html->tag('span', $html->link(__('view commits',true), $chaw->url((array)$CurrentProject, array(
+ 'admin' => false,
+ 'controller' => 'commits', 'action' => 'index'
+ )), array('class' => 'history')));
+
endif;
/*
@@ -69,11 +84,6 @@
'controller' => 'projects', 'action' => 'index', 'ext' => 'tar'
), array('class' => 'detail')));
*/
-
- echo $html->tag('span', $html->link(__('view history',true), array(
- 'admin' => false,
- 'controller' => 'commits', 'action' => 'index'
- ), array('class' => 'history')));
?>
</p>
</div>
diff --git a/webroot/css/chaw.css b/webroot/css/chaw.css
index 5eec62e..88697cb 100644
--- a/webroot/css/chaw.css
+++ b/webroot/css/chaw.css
@@ -1034,6 +1034,9 @@ div.comments {
}
/* History */
+.history {
+ margin-bottom: 20px;
+}
.history h3 {
color: #333;
}
