From 6c83169f1ce4e99683e86c3c2398fd1b47050fd1 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Mon, 2 Feb 2009 17:38:48 +0100 Subject: [PATCH] Fixed the submission of a code review and the display. The display of a code review was crashing when a new file was added in the diff. The form to submit a review now proposes directly a choice of commits. --- src/IDF/Form/ReviewCreate.php | 11 ++++++++++- src/IDF/Views/Review.php | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/IDF/Form/ReviewCreate.php b/src/IDF/Form/ReviewCreate.php index 6a901b5..19e7c8a 100644 --- a/src/IDF/Form/ReviewCreate.php +++ b/src/IDF/Form/ReviewCreate.php @@ -59,12 +59,21 @@ class IDF_Form_ReviewCreate extends Pluf_Form 'rows' => 7, ), )); + $commits = Pluf::factory('IDF_Commit')->getList(array('order' => 'creation_dtime DESC', + 'nb' => 10)); + $choices = array(); + foreach ($commits as $c) { + $id = (strlen($c->scm_id) > 10) ? substr($c->scm_id, 0, 10) : $c->scm_id; + $ext = (mb_strlen($c->summary) > 50) ? mb_substr($c->summary, 0, 47).'...' : $c->summary; + $choices[$id.' - '.$ext] = $c->scm_id; + } $this->fields['commit'] = new Pluf_Form_Field_Varchar( array('required' => true, 'label' => __('Commit'), 'initial' => '', + 'widget' => 'Pluf_Form_Widget_SelectInput', 'widget_attrs' => array( - 'size' => 42, + 'choices' => $choices, ), )); $upload_path = Pluf::f('upload_issue_path', false); diff --git a/src/IDF/Views/Review.php b/src/IDF/Views/Review.php index 8a53a38..1ebe5c8 100644 --- a/src/IDF/Views/Review.php +++ b/src/IDF/Views/Review.php @@ -208,7 +208,6 @@ class IDF_Views_Review $reviewers = array(); foreach ($diff->files as $filename => $def) { $fileinfo = $scm->getFileInfo($filename, $patch->get_commit()->scm_id); - $sql = new Pluf_SQL('cfile=%s', array($filename)); $cts = $patch->get_filecomments_list(array('filter'=>$sql->gen(), 'order'=>'creation_dtime ASC')); @@ -216,7 +215,7 @@ class IDF_Views_Review $reviewers[] = $ct->get_submitter(); } if (count($def['chunks'])) { - $orig_file = $scm->getBlob($fileinfo); + $orig_file = ($fileinfo) ? $scm->getBlob($fileinfo) : ''; $files[$filename] = array( $diff->fileCompare($orig_file, $def, $filename), $form->f->{md5($filename)},