Initial commit

This commit is contained in:
Nathan Adams
2013-07-20 17:41:56 -05:00
commit 3b1e713fc4
606 changed files with 136001 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
From ec6cb8b19ee3a08f48625181d6a74744b3950e90 Mon Sep 17 00:00:00 2001
From: Manuel Eidenberger <eidenberger@...>
Date: Mon, 2 Feb 2009 15:11:23 +0100
Subject: [PATCH] Some configuration variables have been added in order to manually set svn and svnlook binarie paths (see issue 123)
---
src/IDF/Scm/Svn.php | 24 ++++++++++++------------
src/IDF/conf/idf.php-dist | 8 ++++++++
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php
index e2f7a61..e1359c7 100644
--- a/src/IDF/Scm/Svn.php
+++ b/src/IDF/Scm/Svn.php
@@ -108,7 +108,7 @@ class IDF_Scm_Svn
}
// Else, test the path on revision
- $cmd = sprintf('svn info --xml --username=%s --password=%s %s@%s',
+ $cmd = sprintf(Pluf::f('svn_path').' info --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
@@ -190,7 +190,7 @@ class IDF_Scm_Svn
*/
private function getCommitMessage($file, $rev='HEAD')
{
- $cmd = sprintf('svn log --xml --limit 1 --username=%s --password=%s %s@%s',
+ $cmd = sprintf(Pluf::f('svn_path').' log --xml --limit 1 --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($file),
diff --git a/src/IDF/conf/idf.php-dist b/src/IDF/conf/idf.php-dist
index 8aca31f..abb4ecd 100644
--- a/src/IDF/conf/idf.php-dist
+++ b/src/IDF/conf/idf.php-dist
@@ -208,4 +208,12 @@ $cfg['allowed_scm'] = array('git' => 'IDF_Scm_Git',
# variables not being set correctly. Note the trailing space.
# $cfg['idf_exec_cmd_prefix'] = '/usr/bin/env -i ';
+# Path to svn and svnlook binaries. In some cases, it is sometimes
+# necessary to define absolut path to these two binaries, for example:
+# $cfg['svn_path'] = 'svn';
+# $cfg['svnlook_path'] = 'svnlook_path';
+# This is only necessary if svn and svnlook binaries are not set in $PATH
+$cfg['svn_path'] = 'svn';
+$cfg['svnlook_path'] = 'svnlook';
+
return $cfg;
--
1.5.4.3

View File

@@ -0,0 +1,73 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Test the diff parser.
*/
class IDF_Tests_TestDiff extends UnitTestCase
{
public function __construct()
{
parent::__construct('Test the diff parser.');
}
//
// IDF_Diff::mergeChunks() is now private, so this test needs to be rewritten
//
//public function testBinaryDiff()
//{
// $diff_content = file_get_contents(dirname(__FILE__).'/test-diff.diff');
// $orig = file_get_contents(dirname(__FILE__).'/test-diff-view.html');
// $diff = new IDF_Diff($diff_content);
// $diff->parse();
// $def = $diff->files['src/IDF/templates/idf/issues/view.html'];
//
// $orig_lines = preg_split("/\015\012|\015|\012/", $orig);
// $merged = $diff->mergeChunks($orig_lines, $def, 10);
// $lchunk = end($merged);
// $lline = end($lchunk);
// $this->assertEqual(array('', '166', '{/if}{/block}'),
// $lline);
//}
public function testDiffWithHeaders()
{
$diff_content = file_get_contents(dirname(__FILE__).'/0001-Some-configuration-variables-have-been-added-in-orde.patch');
$diff = new IDF_Diff($diff_content);
$diff->parse();
$this->assertEqual(2, count($diff->files));
$this->assertEqual(12, count($diff->files['src/IDF/conf/idf.php-dist']['chunks'][0]));
}
public function testDiffRemoveOneLine()
{
$diff_content = file_get_contents(dirname(__FILE__).'/test-diff-remove-oneline.diff');
$diff = new IDF_Diff($diff_content);
$diff->parse();
$this->assertEqual(2, count($diff->files));
$this->assertEqual(array(280, 288, ''),
$diff->files['src/IDF/Scm/Git.php']['chunks'][1][2]);
$this->assertEqual(7, count($diff->files['src/IDF/Scm/Git.php']['chunks'][1]));
}
}

View File

@@ -0,0 +1,47 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Tests some of the FileUtils
*/
class IDF_Tests_TestFileUtil extends UnitTestCase
{
public function __construct()
{
parent::__construct('Test the file utils.');
}
public function testGetMimeType()
{
$files = array(
'whatever.php' => 'application/x-httpd-php',
'whatever.pht' => 'application/x-httpd-php',
'README' => 'text/plain',
);
foreach ($files as $file => $mime) {
$m = IDF_Views_Source::getMimeType($file);
$this->assertEqual($mime, $m[0]);
}
}
}

View File

@@ -0,0 +1,87 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Test the git class.
*/
class IDF_Tests_TestGit extends UnitTestCase
{
public function __construct()
{
parent::__construct('Test the git class.');
}
public function testParseLog()
{
$log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/test-log.txt'));
$log = IDF_Scm_Git::parseLog($log_lines, 3);
$this->assertEqual('Fixed the middleware to correctly return a 404 error if the project is', $log[0]->title);
}
/**
* parse a log encoded in iso 8859-1
*/
public function testParseIsoLog()
{
$log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/data/git-log-iso-8859-1.txt'));
$log = IDF_Scm_Git::parseLog($log_lines);
$titles = array(
array('Quick Profiler entfernt', 'UTF-8'),
array('Anwendungsmenu Divider eingefügt', 'ISO-8859-1'),
array('Anwendungen aufäumen', 'ISO-8859-1'),
);
foreach ($log as $change) {
list($title, $senc) = array_shift($titles);
list($conv, $encoding) = IDF_Commit::toUTF8($change->title, true);
$this->assertEqual($title, $conv);
$this->assertEqual($senc, $encoding);
}
}
/**
* parse a log encoded in iso 8859-2
*/
public function testParseIsoLog2()
{
$log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/data/git-log-iso-8859-2.txt'));
$log = IDF_Scm_Git::parseLog($log_lines);
$titles = array(
array('Doda³em model','ISO-8859-1'),
array('Doda³em model','ISO-8859-1'),
// The Good result is 'Dodałem model', the
// problem is that in that case, one cannot
// distinguish between latin1 and latin2. We
// will need to add a way for the project
// admin to set the priority between the
// encodings.
);
foreach ($log as $change) {
list($title, $senc) = array_shift($titles);
list($conv, $encoding) = IDF_Commit::toUTF8($change->title, true);
$this->assertEqual($title, $conv);
$this->assertEqual($senc, $encoding);
}
}
}

View File

@@ -0,0 +1,138 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
/**
* Test the creation/modification of a project.
*/
class IDF_Tests_TestIssue extends UnitTestCase
{
public $projects = array();
public $users = array();
public function __construct()
{
parent::__construct('Test creation/modification of issues.');
}
/**
* Create 2 projects to work with and 2 users.
*/
public function setUp()
{
$this->projects = array();
$this->users = array();
for ($i=1;$i<3;$i++) {
$project = new IDF_Project();
$project->name = 'Test project '.$i;
$project->shortname = 'test'.$i;
$project->description = sprintf('This is a test project %d.', $i);
$project->create();
$this->projects[] = $project;
$user = new Pluf_User();
$user->last_name = 'user'.$i;
$user->login = 'user'.$i;
$user->email = 'user'.$i.'@example.com';
$user->create();
$this->users[] = $user;
}
}
public function tearDown()
{
// This will drop cascading issues, comments and tags.
foreach ($this->projects as $proj) {
$proj->delete();
}
foreach ($this->users as $u) {
$u->delete();
}
}
public function testCreate()
{
$issue = new IDF_Issue();
$issue->project = $this->projects[0];
$issue->summary = 'This is a test issue';
$issue->submitter = $this->users[0];
$issue->create();
$this->assertEqual(1, $issue->id);
$this->assertIdentical(null, $issue->get_owner());
$this->assertNotIdentical(null, $issue->get_submitter());
}
public function testCreateMultiple()
{
for ($i=1;$i<11;$i++) {
$issue = new IDF_Issue();
$issue->project = $this->projects[0];
$issue->summary = 'This is a test issue '.$i;
$issue->submitter = $this->users[0];
$issue->owner = $this->users[1];
$issue->create();
}
for ($i=11;$i<16;$i++) {
$issue = new IDF_Issue();
$issue->project = $this->projects[1];
$issue->summary = 'This is a test issue '.$i;
$issue->submitter = $this->users[1];
$issue->create();
}
$this->assertEqual(10,
$this->projects[0]->get_issues_list()->count());
$this->assertEqual(5,
$this->projects[1]->get_issues_list()->count());
$this->assertEqual(5,
$this->users[1]->get_submitted_issue_list()->count());
$this->assertEqual(10,
$this->users[0]->get_submitted_issue_list()->count());
$this->assertEqual(10,
$this->users[1]->get_owned_issue_list()->count());
$this->assertEqual(0,
$this->users[1]->get_owned_issue_list(array('filter' => 'project='.(int)$this->projects[1]->id))->count());
$this->assertEqual(10,
$this->users[1]->get_owned_issue_list(array('filter' => 'project='.(int)$this->projects[0]->id))->count());
}
public function testAddIssueComment()
{
$issue = new IDF_Issue();
$issue->project = $this->projects[0];
$issue->summary = 'This is a test issue';
$issue->submitter = $this->users[0];
$issue->create();
$ic = new IDF_IssueComment();
$ic->issue = $issue;
$ic->submitter = $this->users[0];
$ic->content = 'toto';
$changes = array('s' => 'New summary',
'st' => 'Active',
't' => '-OS:Linux OS:Windows');
$ic->changes = $changes;
$ic->create();
$comments = $issue->get_comments_list();
$this->assertEqual($changes, $comments[0]->changes);
}
}

View File

@@ -0,0 +1,239 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
require_once("simpletest/autorun.php");
/**
* Test the monotone class.
*/
class IDF_Tests_TestMonotone extends UnitTestCase
{
private $tmpdir, $dbfile, $mtnInstance;
private function mtnCall($args, $stdin = null, $dir = null)
{
// if you have an SSH agent running for key caching,
// please disable it
$cmdline = array("mtn",
"--confdir", $this->tmpdir,
"--db", $this->dbfile,
"--norc",
"--timestamps");
$cmdline = array_merge($cmdline, $args);
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "{$this->tmpdir}/mtn-errors", "a")
);
$pipes = array();
$dir = !empty($dir) ? $dir : $this->tmpdir;
$process = proc_open(implode(" ", $cmdline),
$descriptorspec,
$pipes,
$dir);
if (!is_resource($process)) {
throw new Exception("could not create process");
}
if (!empty($stdin)) {
fwrite($pipes[0], $stdin);
fclose($pipes[0]);
}
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$ret = proc_close($process);
if ($ret != 0) {
throw new Exception(
"call ended with a non-zero error code (complete cmdline was: ".
implode(" ", $cmdline).")"
);
}
return $stdout;
}
public function __construct()
{
parent::__construct("Test the monotone class.");
$this->tmpdir = sys_get_temp_dir() . "/mtn-test";
$this->dbfile = "{$this->tmpdir}/test.mtn";
set_include_path(get_include_path() . ":../../../pluf-master/src");
require_once("Pluf.php");
Pluf::start(dirname(__FILE__)."/../conf/idf.php");
// Pluf::f() mocking
$GLOBALS['_PX_config']['mtn_repositories'] = "{$this->tmpdir}/%s.mtn";
}
private static function deleteRecursive($dirname)
{
if (is_dir($dirname))
$dir_handle=opendir($dirname);
while ($file = readdir($dir_handle)) {
if ($file!="." && $file!="..") {
if (!is_dir($dirname."/".$file)) {
unlink ($dirname."/".$file);
continue;
}
self::deleteRecursive($dirname."/".$file);
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
public function setUp()
{
if (is_dir($this->tmpdir)) {
self::deleteRecursive($this->tmpdir);
}
mkdir($this->tmpdir);
$this->mtnCall(array("db", "init"));
$this->mtnCall(array("genkey", "test@test.de"), "\n\n");
$workspaceRoot = "{$this->tmpdir}/test-workspace";
mkdir($workspaceRoot);
$this->mtnCall(array("setup", "-b", "testbranch", "."), null, $workspaceRoot);
file_put_contents("$workspaceRoot/foo", "blubber");
$this->mtnCall(array("add", "foo"), null, $workspaceRoot);
$this->mtnCall(array("commit", "-m", "initial"), null, $workspaceRoot);
file_put_contents("$workspaceRoot/bar", "blafoo");
mkdir("$workspaceRoot/subdir");
file_put_contents("$workspaceRoot/subdir/bla", "blabla");
$this->mtnCall(array("add", "-R", "--unknown"), null, $workspaceRoot);
$this->mtnCall(array("commit", "-m", "second"), null, $workspaceRoot);
$rev = $this->mtnCall(array("au", "get_base_revision_id"), null, $workspaceRoot);
$this->mtnCall(array("tag", rtrim($rev), "release-1.0"));
$project = new IDF_Project();
$project->shortname = "test";
$this->mtnInstance = new IDF_Scm_Monotone($project);
}
public function testIsAvailable()
{
$this->assertTrue($this->mtnInstance->isAvailable());
}
public function testGetBranches()
{
$branches = $this->mtnInstance->getBranches();
$this->assertEqual(1, count($branches));
list($key, $value) = each($branches);
$this->assertEqual("h:testbranch", $key);
$this->assertEqual("testbranch", $value);
}
public function testGetTags()
{
$tags = $this->mtnInstance->getTags();
$this->assertEqual(1, count($tags));
list($key, $value) = each($tags);
$this->assertEqual("t:release-1.0", $key);
$this->assertEqual("release-1.0", $value);
}
public function testInBranches()
{
$revOut = $this->mtnCall(array("au", "select", "b:testbranch"));
$revs = preg_split('/\n/', $revOut, -1, PREG_SPLIT_NO_EMPTY);
$branches = $this->mtnInstance->inBranches($revs[0], null);
$this->assertEqual(1, count($branches));
$this->assertEqual("h:testbranch", $branches[0]);
$branches = $this->mtnInstance->inBranches("t:release-1.0", null);
$this->assertEqual(1, count($branches));
$this->assertEqual("h:testbranch", $branches[0]);
}
public function testInTags()
{
$rev = $this->mtnCall(array("au", "select", "t:release-1.0"));
$tags = $this->mtnInstance->inTags(rtrim($rev), null);
$this->assertEqual(1, count($tags));
$this->assertEqual("t:release-1.0", $tags[0]);
// pick the first (root) revisions in this database
$rev = $this->mtnCall(array("au", "roots"));
$tags = $this->mtnInstance->inTags(rtrim($rev), null);
$this->assertEqual(0, count($tags));
}
public function testGetTree()
{
$files = $this->mtnInstance->getTree("t:release-1.0");
$this->assertEqual(3, count($files));
$this->assertEqual("bar", $files[0]->file);
$this->assertEqual("blob", $files[0]->type);
$this->assertEqual(6, $files[0]->size); // "blafoo"
$this->assertEqual("second\n", $files[0]->log);
$this->assertEqual("foo", $files[1]->file);
$this->assertEqual("blob", $files[1]->type);
$this->assertEqual(7, $files[1]->size); // "blubber"
$this->assertEqual("initial\n", $files[1]->log);
$this->assertEqual("subdir", $files[2]->file);
$this->assertEqual("tree", $files[2]->type);
$this->assertEqual(0, $files[2]->size);
$files = $this->mtnInstance->getTree("t:release-1.0", "subdir");
$this->assertEqual(1, count($files));
$this->assertEqual("bla", $files[0]->file);
$this->assertEqual("subdir/bla", $files[0]->fullpath);
$this->assertEqual("blob", $files[0]->type);
$this->assertEqual(6, $files[0]->size); // "blabla"
$this->assertEqual("second\n", $files[0]->log);
}
public function testvalidateRevision()
{
$this->assertEquals(IDF_Scm::REVISION_VALID, $this->mtnInstance->validateRevision("t:release-1.0"));
$this->assertEquals(IDF_Scm::REVISION_INVALID, $this->mtnInstance->validateRevision("abcdef12345"));
}
}

View File

@@ -0,0 +1,77 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
/**
* Test the creation/modification of a project.
*/
class IDF_Tests_TestProject extends UnitTestCase
{
public function __construct()
{
parent::__construct('Test creation/modification of a project.');
}
public function tearDown()
{
foreach (Pluf::factory('IDF_Project')->getList() as $proj) {
$proj->delete();
}
}
public function testCreate()
{
$gproj = Pluf::factory('IDF_Project')->getList();
$this->assertEqual(0, $gproj->count());
$project = new IDF_Project();
$project->name = 'Test project';
$project->shortname = 'test';
$project->description = 'This is a test project.';
$project->create();
$id = $project->id;
$p2 = new IDF_Project($id);
$this->assertEqual($p2->shortname, $project->shortname);
}
public function testMultipleCreate()
{
$project = new IDF_Project();
$project->name = 'Test project';
$project->shortname = 'test';
$project->description = 'This is a test project.';
$project->create();
try {
$project = new IDF_Project();
$project->name = 'Test project';
$project->shortname = 'test';
$project->description = 'This is a test project.';
$project->create();
// if here it as failed
$this->fail('It should not be possible to create 2 projects with same shortname');
} catch (Exception $e) {
$this->pass();
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Test the source class.
*/
class IDF_Tests_TestSource extends UnitTestCase
{
public function __construct()
{
parent::__construct('Test the source class.');
}
public function testRegexCommit()
{
$regex = '#^/p/([\-\w]+)/source/tree/([^\/]+)/(.*)$#';
$tests = array('/p/test_project/source/tree/default/current/sources' =>
array('test_project', 'default', 'current/sources'),
'/p/test_project/source/tree/3.6/current/sources' =>
array('test_project', '3.6', 'current/sources'),
);
foreach ($tests as $test => $res) {
$m = array();
$t = preg_match($regex, $test, $m);
$this->assertEqual($res[0], $m[1]);
$this->assertEqual($res[1], $m[2]);
$this->assertEqual($res[2], $m[3]);
}
}
}

View File

@@ -0,0 +1,44 @@
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Test the synchro with git.
*/
class IDF_Tests_TestSyncGit extends UnitTestCase
{
public function __construct()
{
parent::__construct('Test the synchro with git.');
}
public function testParsePath()
{
$regex = Pluf::factory('IDF_Plugin_SyncGit_Serve')->preg;
$no_matches = array('foo', "'ev!l'", "'something/../evil'");
foreach ($no_matches as $test) {
preg_match($regex, $test, $matches);
$this->assertEqual(false, isset($matches['path']));
}
}
}

View File

@@ -0,0 +1,19 @@
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Fri Jul 3 01:44:11 2009 +0200
Quick Profiler entfernt
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Wed Jul 1 15:51:22 2009 +0200
Anwendungsmenu Divider eingef<65>gt
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Wed Jul 1 15:05:41 2009 +0200
Anwendungen auf<75>umen

View File

@@ -0,0 +1,12 @@
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Fri Jul 3 01:44:11 2009 +0200
Doda<64>em model
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Fri Jul 3 01:44:11 2009 +0200
Doda<64>em model

View File

@@ -0,0 +1,53 @@
diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php
index 5f35e0b..ebe0530 100644
--- a/src/IDF/Scm/Git.php
+++ b/src/IDF/Scm/Git.php
@@ -250,14 +250,22 @@ class IDF_Scm_Git
* Get commit details.
*
* @param string Commit ('HEAD').
+ * @param bool Get commit diff (false).
* @return array Changes.
*/
- public function getCommit($commit='HEAD')
+ public function getCommit($commit='HEAD', $getdiff=false)
{
- $cmd = sprintf('GIT_DIR=%s git show --date=iso --pretty=format:%s %s',
- escapeshellarg($this->repo),
- "'".$this->mediumtree_fmt."'",
- escapeshellarg($commit));
+ if ($getdiff) {
+ $cmd = sprintf('GIT_DIR=%s git show --date=iso --pretty=format:%s %s',
+ escapeshellarg($this->repo),
+ "'".$this->mediumtree_fmt."'",
+ escapeshellarg($commit));
+ } else {
+ $cmd = sprintf('GIT_DIR=%s git log -1 --date=iso --pretty=format:%s %s',
+ escapeshellarg($this->repo),
+ "'".$this->mediumtree_fmt."'",
+ escapeshellarg($commit));
+ }
$out = array();
IDF_Scm::exec($cmd, $out);
$log = array();
@@ -278,7 +286,6 @@ class IDF_Scm_Git
return $out[0];
}
-
/**
* Get latest changes.
*
diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php
index ad24ed6..e5b4f1b 100644
--- a/src/IDF/Views/Source.php
+++ b/src/IDF/Views/Source.php
@@ -216,7 +216,7 @@ class IDF_Views_Source
}
$title = sprintf(__('%s Commit Details'), (string) $request->project);
$page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit);
- $cobject = $scm->getCommit($commit);
+ $cobject = $scm->getCommit($commit, true);
$rcommit = IDF_Commit::getOrAdd($cobject, $request->project);
$diff = new IDF_Diff($cobject->changes);
$diff->parse();

View File

@@ -0,0 +1,125 @@
{extends "idf/issues/base.html"}
{block titleicon}{if $form}<form class="star" method="post" action="{url 'IDF_Views_Issue::star', array($project.shortname, $issue.id)}"><input type="image" src="{if $starred}{media '/idf/img/star.png'}{else}{media '/idf/img/star-grey.png'}{/if}" name="submit" /></form> {/if}{/block}
{block body}
{assign $i = 0}
{assign $nc = $comments.count()}
{foreach $comments as $c}
<div class="issue-comment{if $i == 0} issue-comment-first{/if}{if $i == ($nc-1)} issue-comment-last{/if}" id="ic{$c.id}">{assign $who = $c.get_submitter()}{aurl 'whourl', 'IDF_Views_User::view', array($who.login)}
{if $i == 0}
<p>{blocktrans}Reported by <a href="{$whourl}">{$who}</a>, {$c.creation_dtime|date}{/blocktrans}</p>
{else}
{aurl 'url', 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
{assign $id = $c.id}
{assign $url = $url~'#ic'~$c.id}
<p>{blocktrans}Comment <a href="{$url}">{$i}</a> by <a href="{$whourl}">{$who}</a>, {$c.creation_dtime|date}{/blocktrans}</p>
{/if}
<pre class="issue-comment-text">{if strlen($c.content) > 0}{issuetext $c.content, $request}{else}<i>{trans '(No comments were given for this change.)'}</i>{/if}</pre>
{assign $attachments = $c.get_attachment_list()}
{if $attachments.count() > 0}
<hr align="left" class="attach" />
<ul>
{foreach $attachments as $a}<li><a href="{url 'IDF_Views_Issue::getAttachment', array($project.shortname, $a.id, $a.filename)}">{$a.filename}</a> - {$a.filesize|size}</li>{/foreach}
</ul>{/if}
{if $i> 0 and $c.changedIssue()}
<div class="issue-changes">
{foreach $c.changes as $w => $v}
<strong>{if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'st'}{trans 'Status:'}{/if}{if $w == 'ow'}{trans 'Owner:'}{/if}{if $w == 'lb'}{trans 'Labels:'}{/if}</strong> {if $w == 'lb'}{assign $l = implode(', ', $v)}{$l}{else}{$v}{/if}<br />
{/foreach}
</div>
{/if}
</div>{assign $i = $i + 1}{if $i == $nc and false == $form}
<div class="issue-comment-signin">
{aurl 'url', 'IDF_Views::login'}{blocktrans}<a href="{$url}">Sign in</a> to reply to this comment.{/blocktrans}
</div>
{/if}
{/foreach}
{if $form}
<hr />
{if $form.errors}
<div class="px-message-error">
<p>{trans 'The form contains some errors. Please correct them to change the issue.'}</p>
{if $form.get_top_errors}
{$form.render_top_errors|unsafe}
{/if}
</div>
{/if}
{if $closed and (!$isOwner and !$isMember)}
<p><img src="{media '/idf/img/warning.png'}" style="vertical-align: text-bottom;" alt=" " /> {blocktrans}This issue is marked as closed, add a comment only if you think this issue is still valid and more work is needed to fully fix it.{/blocktrans}</p>
{/if}
<form method="post" enctype="multipart/form-data" action="{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}" >
<table class="form" summary="">
<tr>
<th><strong>{$form.f.content.labelTag}:</strong></th>
<td>{if $form.f.content.errors}{$form.f.content.fieldErrors}{/if}
{$form.f.content|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.attachment.labelTag}:</th>
<td>{if $form.f.attachment.errors}{$form.f.attachment.fieldErrors}{/if}
{$form.f.attachment|unsafe}
</td>
</tr>{if $isOwner or $isMember}
<tr>
<th><strong>{$form.f.summary.labelTag}:</strong></th>
<td>{if $form.f.summary.errors}{$form.f.summary.fieldErrors}{/if}
{$form.f.summary|unsafe}
</td>
</tr>
<tr>
<th><strong>{$form.f.status.labelTag}:</strong></th>
<td>{if $form.f.status.errors}{$form.f.status.fieldErrors}{/if}
{$form.f.status|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.owner.labelTag}:</th>
<td>{if $form.f.owner.errors}{$form.f.owner.fieldErrors}{/if}
{$form.f.owner|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.label1.labelTag}:</th>
<td>
{if $form.f.label1.errors}{$form.f.label1.fieldErrors}{/if}{$form.f.label1|unsafe}
{if $form.f.label2.errors}{$form.f.label2.fieldErrors}{/if}{$form.f.label2|unsafe}
{if $form.f.label3.errors}{$form.f.label3.fieldErrors}{/if}{$form.f.label3|unsafe}<br />
{if $form.f.label4.errors}{$form.f.label4.fieldErrors}{/if}{$form.f.label4|unsafe}
{if $form.f.label5.errors}{$form.f.label5.fieldErrors}{/if}{$form.f.label5|unsafe}
{if $form.f.label6.errors}{$form.f.label6.fieldErrors}{/if}{$form.f.label6|unsafe}
</td>
</tr>{/if}
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="{trans 'Submit Changes'}" name="submit" /> | <a href="{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}">{trans 'Cancel'}</a>
</td>
</tr>
</table>
</form>
{/if}
{/block}
{block context}
<div class="issue-info">
{assign $submitter = $issue.get_submitter()}{aurl 'url', 'IDF_Views_User::view', array($submitter.login)}
<p><strong>{trans 'Created:'}</strong> <span class="nobrk">{$issue.creation_dtime|dateago}</span> <span class="nobrk">{blocktrans}by <a href="{$url}">{$submitter}</a>{/blocktrans}</span></p>
{if $issue.modif_dtime != $issue.creation_dtime}<p>
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$issue.modif_dtime|dateago}</span></p>{/if}
<p>
<strong>{trans 'Status:'}</strong> {$issue.get_status.name}</p>
{if $issue.get_owner != null}<p>{aurl 'url', 'IDF_Views_User::view', array($issue.get_owner().login)}
<strong>{trans 'Owner:'}</strong> <a href="{$url}">{$issue.get_owner}</a>
</p>{/if}{assign $tags = $issue.get_tags_list()}{if $tags.count()}
<p>
<strong>{trans 'Labels:'}</strong><br />
{foreach $tags as $tag}{aurl 'url', 'IDF_Views_Issue::listLabel', array($project.shortname, $tag.id, 'open')}
<span class="label"><a href="{$url}" class="label"><strong>{$tag.class}:</strong>{$tag.name}</a></span><br />
{/foreach}
</p>{/if}
</div>
{/block}
{block javascript}{if $form}{include 'idf/issues/js-autocomplete.html'}{/if}{/block}

View File

@@ -0,0 +1,515 @@
diff --git a/src/IDF/Form/IssueCreate.php b/src/IDF/Form/IssueCreate.php
index 0743e72..67afca7 100644
--- a/src/IDF/Form/IssueCreate.php
+++ b/src/IDF/Form/IssueCreate.php
@@ -72,8 +72,9 @@ class IDF_Form_IssueCreate extends Pluf_Form
// We add .dummy to try to mitigate security issues in the
// case of someone allowing the upload path to be accessible
// to everybody.
- $filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
- $this->fields['attachment'] = new Pluf_Form_Field_File(
+ for ($i=1;$i<4;$i++) {
+ $filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
+ $this->fields['attachment'.$i] = new Pluf_Form_Field_File(
array('required' => false,
'label' => __('Attach a file'),
'move_function_params' =>
@@ -83,6 +84,7 @@ class IDF_Form_IssueCreate extends Pluf_Form
)
)
);
+ }
if ($this->show_full) {
$this->fields['status'] = new Pluf_Form_Field_Varchar(
@@ -195,6 +197,21 @@ class IDF_Form_IssueCreate extends Pluf_Form
}
/**
+ * Clean the attachments post failure.
+ */
+ function failed()
+ {
+ $upload_path = Pluf::f('upload_issue_path', false);
+ if ($upload_path == false) return;
+ for ($i=1;$i<4;$i++) {
+ if (!empty($this->cleaned_data['attachment'.$i]) and
+ file_exists($upload_path.'/'.$this->cleaned_data['attachment'.$i])) {
+ @unlink($upload_path.'/'.$this->cleaned_data['attachment'.$i]);
+ }
+ }
+ }
+
+ /**
* Save the model in the database.
*
* @param bool Commit in the database or not. If not, the object
@@ -203,61 +220,63 @@ class IDF_Form_IssueCreate extends Pluf_Form
*/
function save($commit=true)
{
- if ($this->isValid()) {
- // Add a tag for each label
- $tags = array();
- if ($this->show_full) {
- for ($i=1;$i<7;$i++) {
- if (strlen($this->cleaned_data['label'.$i]) > 0) {
- if (strpos($this->cleaned_data['label'.$i], ':') !== false) {
- list($class, $name) = explode(':', $this->cleaned_data['label'.$i], 2);
- list($class, $name) = array(trim($class), trim($name));
- } else {
- $class = 'Other';
- $name = trim($this->cleaned_data['label'.$i]);
- }
- $tags[] = IDF_Tag::add($name, $this->project, $class);
+ if (!$this->isValid()) {
+ throw new Exception(__('Cannot save the model from an invalid form.'));
+ }
+ // Add a tag for each label
+ $tags = array();
+ if ($this->show_full) {
+ for ($i=1;$i<7;$i++) {
+ if (strlen($this->cleaned_data['label'.$i]) > 0) {
+ if (strpos($this->cleaned_data['label'.$i], ':') !== false) {
+ list($class, $name) = explode(':', $this->cleaned_data['label'.$i], 2);
+ list($class, $name) = array(trim($class), trim($name));
+ } else {
+ $class = 'Other';
+ $name = trim($this->cleaned_data['label'.$i]);
}
+ $tags[] = IDF_Tag::add($name, $this->project, $class);
}
- } else {
- $tags[] = IDF_Tag::add('Medium', $this->project, 'Priority');
- $tags[] = IDF_Tag::add('Defect', $this->project, 'Type');
- }
- // Create the issue
- $issue = new IDF_Issue();
- $issue->project = $this->project;
- $issue->submitter = $this->user;
- if ($this->show_full) {
- $issue->status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
- $issue->owner = self::findUser($this->cleaned_data['owner']);
- } else {
- $_t = $this->project->getTagIdsByStatus('open');
- $issue->status = new IDF_Tag($_t[0]); // first one is the default
- $issue->owner = null;
- }
- $issue->summary = trim($this->cleaned_data['summary']);
- $issue->create();
- foreach ($tags as $tag) {
- $issue->setAssoc($tag);
}
- // add the first comment
- $comment = new IDF_IssueComment();
- $comment->issue = $issue;
- $comment->content = $this->cleaned_data['content'];
- $comment->submitter = $this->user;
- $comment->create();
- // If we have a file, create the IDF_IssueFile and attach
- // it to the comment.
- if ($this->cleaned_data['attachment']) {
+ } else {
+ $tags[] = IDF_Tag::add('Medium', $this->project, 'Priority');
+ $tags[] = IDF_Tag::add('Defect', $this->project, 'Type');
+ }
+ // Create the issue
+ $issue = new IDF_Issue();
+ $issue->project = $this->project;
+ $issue->submitter = $this->user;
+ if ($this->show_full) {
+ $issue->status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
+ $issue->owner = self::findUser($this->cleaned_data['owner']);
+ } else {
+ $_t = $this->project->getTagIdsByStatus('open');
+ $issue->status = new IDF_Tag($_t[0]); // first one is the default
+ $issue->owner = null;
+ }
+ $issue->summary = trim($this->cleaned_data['summary']);
+ $issue->create();
+ foreach ($tags as $tag) {
+ $issue->setAssoc($tag);
+ }
+ // add the first comment
+ $comment = new IDF_IssueComment();
+ $comment->issue = $issue;
+ $comment->content = $this->cleaned_data['content'];
+ $comment->submitter = $this->user;
+ $comment->create();
+ // If we have a file, create the IDF_IssueFile and attach
+ // it to the comment.
+ for ($i=1;$i<4;$i++) {
+ if ($this->cleaned_data['attachment'.$i]) {
$file = new IDF_IssueFile();
- $file->attachment = $this->cleaned_data['attachment'];
+ $file->attachment = $this->cleaned_data['attachment'.$i];
$file->submitter = $this->user;
$file->comment = $comment;
$file->create();
}
- return $issue;
}
- throw new Exception(__('Cannot save the model from an invalid form.'));
+ return $issue;
}
/**
diff --git a/src/IDF/Form/IssueUpdate.php b/src/IDF/Form/IssueUpdate.php
index 550889e..0d36e72 100644
--- a/src/IDF/Form/IssueUpdate.php
+++ b/src/IDF/Form/IssueUpdate.php
@@ -68,8 +68,9 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
// We add .dummy to try to mitigate security issues in the
// case of someone allowing the upload path to be accessible
// to everybody.
- $filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
- $this->fields['attachment'] = new Pluf_Form_Field_File(
+ for ($i=1;$i<4;$i++) {
+ $filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
+ $this->fields['attachment'.$i] = new Pluf_Form_Field_File(
array('required' => false,
'label' => __('Attach a file'),
'move_function_params' =>
@@ -79,6 +80,7 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
)
)
);
+ }
if ($this->show_full) {
$this->fields['status'] = new Pluf_Form_Field_Varchar(
@@ -124,6 +126,21 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
}
/**
+ * Clean the attachments post failure.
+ */
+ function failed()
+ {
+ $upload_path = Pluf::f('upload_issue_path', false);
+ if ($upload_path == false) return;
+ for ($i=1;$i<4;$i++) {
+ if (!empty($this->cleaned_data['attachment'.$i]) and
+ file_exists($upload_path.'/'.$this->cleaned_data['attachment'.$i])) {
+ @unlink($upload_path.'/'.$this->cleaned_data['attachment'.$i]);
+ }
+ }
+ }
+
+ /**
* We check that something is really changed.
*/
public function clean()
@@ -202,90 +219,92 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
*/
function save($commit=true)
{
- if ($this->isValid()) {
- if ($this->show_full) {
- // Add a tag for each label
- $tags = array();
- $tagids = array();
- for ($i=1;$i<7;$i++) {
- if (strlen($this->cleaned_data['label'.$i]) > 0) {
- if (strpos($this->cleaned_data['label'.$i], ':') !== false) {
- list($class, $name) = explode(':', $this->cleaned_data['label'.$i], 2);
- list($class, $name) = array(trim($class), trim($name));
- } else {
- $class = 'Other';
- $name = trim($this->cleaned_data['label'.$i]);
- }
- $tag = IDF_Tag::add($name, $this->project, $class);
- $tags[] = $tag;
- $tagids[] = $tag->id;
+ if (!$this->isValid()) {
+ throw new Exception(__('Cannot save the model from an invalid form.'));
+ }
+ if ($this->show_full) {
+ // Add a tag for each label
+ $tags = array();
+ $tagids = array();
+ for ($i=1;$i<7;$i++) {
+ if (strlen($this->cleaned_data['label'.$i]) > 0) {
+ if (strpos($this->cleaned_data['label'.$i], ':') !== false) {
+ list($class, $name) = explode(':', $this->cleaned_data['label'.$i], 2);
+ list($class, $name) = array(trim($class), trim($name));
+ } else {
+ $class = 'Other';
+ $name = trim($this->cleaned_data['label'.$i]);
}
+ $tag = IDF_Tag::add($name, $this->project, $class);
+ $tags[] = $tag;
+ $tagids[] = $tag->id;
}
- // Compare between the old and the new data
- $changes = array();
- $oldtags = $this->issue->get_tags_list();
- foreach ($tags as $tag) {
- if (!Pluf_Model_InArray($tag, $oldtags)) {
- if (!isset($changes['lb'])) $changes['lb'] = array();
- if ($tag->class != 'Other') {
- $changes['lb'][] = (string) $tag; //new tag
- } else {
- $changes['lb'][] = (string) $tag->name;
- }
+ }
+ // Compare between the old and the new data
+ $changes = array();
+ $oldtags = $this->issue->get_tags_list();
+ foreach ($tags as $tag) {
+ if (!Pluf_Model_InArray($tag, $oldtags)) {
+ if (!isset($changes['lb'])) $changes['lb'] = array();
+ if ($tag->class != 'Other') {
+ $changes['lb'][] = (string) $tag; //new tag
+ } else {
+ $changes['lb'][] = (string) $tag->name;
}
}
- foreach ($oldtags as $tag) {
- if (!Pluf_Model_InArray($tag, $tags)) {
- if (!isset($changes['lb'])) $changes['lb'] = array();
- if ($tag->class != 'Other') {
- $changes['lb'][] = '-'.(string) $tag; //new tag
- } else {
- $changes['lb'][] = '-'.(string) $tag->name;
- }
+ }
+ foreach ($oldtags as $tag) {
+ if (!Pluf_Model_InArray($tag, $tags)) {
+ if (!isset($changes['lb'])) $changes['lb'] = array();
+ if ($tag->class != 'Other') {
+ $changes['lb'][] = '-'.(string) $tag; //new tag
+ } else {
+ $changes['lb'][] = '-'.(string) $tag->name;
}
}
- // Status, summary and owner
- $status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
- if ($status->id != $this->issue->status) {
- $changes['st'] = $status->name;
- }
- if (trim($this->issue->summary) != trim($this->cleaned_data['summary'])) {
- $changes['su'] = trim($this->cleaned_data['summary']);
- }
- $owner = self::findUser($this->cleaned_data['owner']);
- if ((is_null($owner) and !is_null($this->issue->get_owner()))
- or (!is_null($owner) and is_null($this->issue->get_owner()))
- or ((!is_null($owner) and !is_null($this->issue->get_owner())) and $owner->id != $this->issue->get_owner()->id)) {
- $changes['ow'] = (is_null($owner)) ? '---' : $owner->login;
- }
- // Update the issue
- $this->issue->batchAssoc('IDF_Tag', $tagids);
- $this->issue->summary = trim($this->cleaned_data['summary']);
- $this->issue->status = $status;
- $this->issue->owner = $owner;
}
- // Create the comment
- $comment = new IDF_IssueComment();
- $comment->issue = $this->issue;
- $comment->content = $this->cleaned_data['content'];
- $comment->submitter = $this->user;
- if (!$this->show_full) $changes = array();
- $comment->changes = $changes;
- $comment->create();
- $this->issue->update();
- if ($this->issue->owner != $this->user->id and
- $this->issue->submitter != $this->user->id) {
- $this->issue->setAssoc($this->user); // interested user.
+ // Status, summary and owner
+ $status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
+ if ($status->id != $this->issue->status) {
+ $changes['st'] = $status->name;
}
- if ($this->cleaned_data['attachment']) {
+ if (trim($this->issue->summary) != trim($this->cleaned_data['summary'])) {
+ $changes['su'] = trim($this->cleaned_data['summary']);
+ }
+ $owner = self::findUser($this->cleaned_data['owner']);
+ if ((is_null($owner) and !is_null($this->issue->get_owner()))
+ or (!is_null($owner) and is_null($this->issue->get_owner()))
+ or ((!is_null($owner) and !is_null($this->issue->get_owner())) and $owner->id != $this->issue->get_owner()->id)) {
+ $changes['ow'] = (is_null($owner)) ? '---' : $owner->login;
+ }
+ // Update the issue
+ $this->issue->batchAssoc('IDF_Tag', $tagids);
+ $this->issue->summary = trim($this->cleaned_data['summary']);
+ $this->issue->status = $status;
+ $this->issue->owner = $owner;
+ }
+ // Create the comment
+ $comment = new IDF_IssueComment();
+ $comment->issue = $this->issue;
+ $comment->content = $this->cleaned_data['content'];
+ $comment->submitter = $this->user;
+ if (!$this->show_full) $changes = array();
+ $comment->changes = $changes;
+ $comment->create();
+ $this->issue->update();
+ if ($this->issue->owner != $this->user->id and
+ $this->issue->submitter != $this->user->id) {
+ $this->issue->setAssoc($this->user); // interested user.
+ }
+ for ($i=1;$i<4;$i++) {
+ if ($this->cleaned_data['attachment'.$i]) {
$file = new IDF_IssueFile();
- $file->attachment = $this->cleaned_data['attachment'];
+ $file->attachment = $this->cleaned_data['attachment'.$i];
$file->submitter = $this->user;
$file->comment = $comment;
$file->create();
}
- return $this->issue;
}
- throw new Exception(__('Cannot save the model from an invalid form.'));
+ return $this->issue;
}
}
diff --git a/src/IDF/IssueFile.php b/src/IDF/IssueFile.php
index f4367dd..f0745e8 100644
--- a/src/IDF/IssueFile.php
+++ b/src/IDF/IssueFile.php
@@ -114,6 +114,7 @@ class IDF_IssueFile extends Pluf_Model
$this->filename = substr(basename($file), 0, -6);
$img_extensions = array('jpeg', 'jpg', 'png', 'gif');
$info = pathinfo($this->filename);
+ if (!isset($info['extension'])) $info['extension'] = '';
if (in_array(strtolower($info['extension']), $img_extensions)) {
$this->type = 'img';
} else {
diff --git a/src/IDF/templates/idf/issues/create.html b/src/IDF/templates/idf/issues/create.html
index e8f4a5b..faaa743 100644
--- a/src/IDF/templates/idf/issues/create.html
+++ b/src/IDF/templates/idf/issues/create.html
@@ -24,10 +24,22 @@
{$form.f.content|unsafe}
</td>
</tr>
-<tr>
-<th>{$form.f.attachment.labelTag}:</th>
-<td>{if $form.f.attachment.errors}{$form.f.attachment.fieldErrors}{/if}
-{$form.f.attachment|unsafe}
+<tr id="form-attachment-1">
+<th>{$form.f.attachment1.labelTag}:</th>
+<td>{if $form.f.attachment1.errors}{$form.f.attachment1.fieldErrors}{/if}
+{$form.f.attachment1|unsafe}
+</td>
+</tr>
+<tr id="form-attachment-2">
+<th>{$form.f.attachment2.labelTag}:</th>
+<td>{if $form.f.attachment2.errors}{$form.f.attachment2.fieldErrors}{/if}
+{$form.f.attachment2|unsafe}
+</td>
+</tr>
+<tr id="form-attachment-3">
+<th>{$form.f.attachment3.labelTag}:</th>
+<td>{if $form.f.attachment3.errors}{$form.f.attachment3.fieldErrors}{/if}
+{$form.f.attachment3|unsafe}
</td>
</tr>{if $isOwner or $isMember}
<tr>
@@ -74,7 +86,34 @@
{/block}
{block javascript}
<script type="text/javascript">
-document.getElementById('id_summary').focus()
+document.getElementById('id_summary').focus();{literal}
+$(document).ready(function(){
+
+ // Hide the upload forms, we insert before the first attach file
+ // row an "Attach File" little link.
+ // We hide all the rows.
+ $("#form-attachment-1").before("{/literal}<tr id=\"form-block-0\"><td>&nbsp;</td><td><img style=\"vertical-align: text-bottom;\" src=\"{media '/idf/img/attachment.png'}\" alt=\" \" align=\"bottom\" /><a id=\"form-show-0\" href=\"#\">{trans 'Attach file'}{literal}</a></td></tr>");
+ $("#form-show-0").click(function(){
+ $("#form-attachment-1").show();
+ $("#form-block-0").hide();
+ });
+ $("#form-attachment-1 td").append("<span id=\"form-block-1\"><a id=\"form-show-1\" href=\"#\">{/literal}{trans 'Attach another file'}{literal}</a></span>");
+ $("#form-show-1").click(function(){
+ $("#form-attachment-2").show();
+ $("#form-block-1").hide();
+ });
+ $("#form-attachment-2 td").append("<span id=\"form-block-2\"><a id=\"form-show-2\" href=\"#\">{/literal}{trans 'Attach another file'}{literal}</a></span>");
+ $("#form-show-2").click(function(){
+ $("#form-attachment-3").show();
+ $("#form-block-2").hide();
+ });
+ var j=0;
+ for (j=1;j<4;j=j+1) {
+ $("#form-attachment-"+j).hide();
+ }
+ });
</script>
+{/literal}{/block}
+
{include 'idf/issues/js-autocomplete.html'}{/block}
diff --git a/src/IDF/templates/idf/issues/view.html b/src/IDF/templates/idf/issues/view.html
index cb9e085..ad56d05 100644
--- a/src/IDF/templates/idf/issues/view.html
+++ b/src/IDF/templates/idf/issues/view.html
@@ -59,10 +59,22 @@
{$form.f.content|unsafe}
</td>
</tr>
-<tr>
-<th>{$form.f.attachment.labelTag}:</th>
-<td>{if $form.f.attachment.errors}{$form.f.attachment.fieldErrors}{/if}
-{$form.f.attachment|unsafe}
+<tr id="form-attachment-1">
+<th>{$form.f.attachment1.labelTag}:</th>
+<td>{if $form.f.attachment1.errors}{$form.f.attachment1.fieldErrors}{/if}
+{$form.f.attachment1|unsafe}
+</td>
+</tr>
+<tr id="form-attachment-2">
+<th>{$form.f.attachment2.labelTag}:</th>
+<td>{if $form.f.attachment2.errors}{$form.f.attachment2.fieldErrors}{/if}
+{$form.f.attachment2|unsafe}
+</td>
+</tr>
+<tr id="form-attachment-3">
+<th>{$form.f.attachment3.labelTag}:</th>
+<td>{if $form.f.attachment3.errors}{$form.f.attachment3.fieldErrors}{/if}
+{$form.f.attachment3|unsafe}
</td>
</tr>{if $isOwner or $isMember}
<tr>
@@ -122,4 +134,33 @@
</p>{/if}
</div>
{/block}
-{block javascript}{if $form}{include 'idf/issues/js-autocomplete.html'}{/if}{/block}
+{block javascript}{if $form}{include 'idf/issues/js-autocomplete.html'}
+<script type="text/javascript">
+{literal}
+$(document).ready(function(){
+
+ // Hide the upload forms, we insert before the first attach file
+ // row an "Attach File" little link.
+ // We hide all the rows.
+ $("#form-attachment-1").before("{/literal}<tr id=\"form-block-0\"><td>&nbsp;</td><td><img style=\"vertical-align: text-bottom;\" src=\"{media '/idf/img/attachment.png'}\" alt=\" \" align=\"bottom\" /><a id=\"form-show-0\" href=\"#\">{trans 'Attach file'}{literal}</a></td></tr>");
+ $("#form-show-0").click(function(){
+ $("#form-attachment-1").show();
+ $("#form-block-0").hide();
+ });
+ $("#form-attachment-1 td").append("<span id=\"form-block-1\"><a id=\"form-show-1\" href=\"#\">{/literal}{trans 'Attach another file'}{literal}</a></span>");
+ $("#form-show-1").click(function(){
+ $("#form-attachment-2").show();
+ $("#form-block-1").hide();
+ });
+ $("#form-attachment-2 td").append("<span id=\"form-block-2\"><a id=\"form-show-2\" href=\"#\">{/literal}{trans 'Attach another file'}{literal}</a></span>");
+ $("#form-show-2").click(function(){
+ $("#form-attachment-3").show();
+ $("#form-block-2").hide();
+ });
+ var j=0;
+ for (j=1;j<4;j=j+1) {
+ $("#form-attachment-"+j).hide();
+ }
+ });{/literal}
+</script>
+{/if}{/block}
diff --git a/www/media/idf/img/attachment.png b/www/media/idf/img/attachment.png
new file mode 100644
index 0000000..529bb7f
Binary files /dev/null and b/www/media/idf/img/attachment.png differ

View File

@@ -0,0 +1,210 @@
commit cf9360a1a87f8a98dc506a316055537b95ec245f
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sat Aug 2 09:48:55 2008 +0200
Fixed the middleware to correctly return a 404 error if the project is
not found.
commit 953d7c4ecd37e2c89058b656ee586ae73bfe1e8f
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sat Aug 2 09:48:35 2008 +0200
Added the name of the login view.
commit f4f8f9615ab460b9966509bd60b740c84ec9ecc9
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sat Aug 2 09:42:05 2008 +0200
Added the link to commit and issues in the changelog.
commit 4c5bd8d2be673c9d86d8b6b5108d551982491d5c
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sat Aug 2 09:38:06 2008 +0200
Fixed bug when looking at a commit which is a merge.
When you merge you do not get always a diff of files. This fix correct
that for the case of commit 9a2b8e249acad9f844.
commit fd6031d7f50085b2e42bb539a886fc9175f6fe27
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Aug 1 22:18:58 2008 +0200
Fixed SQL to follow the standards.
commit 83658ac860328568d8570cbbadde565de8348be9
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Aug 1 22:15:49 2008 +0200
Fixed to have standard SQL.
commit 593afd9b8b18efde2a7817d57e8f101112aaa6fe
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Aug 1 22:13:25 2008 +0200
Fix for PostgreSQL.
commit a831c749d849f903f84698c36666affd391aa04d
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Aug 1 22:03:56 2008 +0200
Fixed boolean for PostgreSQL.
commit 7d806325579547facd27a0c44b54872fe9d7fb2d
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Aug 1 00:50:44 2008 +0200
Added code indentation.
commit 80ce87009e0249b7faf1143075bb4006bd2f8e35
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Aug 1 00:38:29 2008 +0200
Added a better commit diff.
commit cb15f036fe91edb9c07ff07f13bc592a8877f3c2
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Thu Jul 31 22:54:02 2008 +0200
Fixed some typos.
commit 1b3a42940d30abb342d9c4b8ff166a586701b784
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Thu Jul 31 22:50:21 2008 +0200
Added the registration procedure.
commit 416d13e249da7d8717ebb15966b9dbbd5c0188ba
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Tue Jul 29 22:33:13 2008 +0200
Added the registration form.
Still need a lot :)
commit c50e218704dcc81eb346cc757e4c1bdbd0808d8b
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Tue Jul 29 21:18:02 2008 +0200
Added a project home.
commit ccf24df13120ae1e64225ec27db1ee647c9df4d4
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Tue Jul 29 15:13:40 2008 +0200
Link to the corresponding tree in the commit view.
commit a6716c77160c9bbb4829eff5c6e11c7b9a4f6d50
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Mon Jul 28 22:09:17 2008 +0200
Added the visualisation of a commit.
commit 3fb47562ce0453af4481b1b470581f5bcbbc6b3b
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Mon Jul 28 20:31:23 2008 +0200
Automatically create links in the issue description and comments.
Link to issues but also commits.
commit 3dbae6272a9f239499038f069f6472dfceb5e73e
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 21:38:49 2008 +0200
Added smooth handling of bad files and commits.
Now simply redirect to the root of the first available branch.
commit 8a0a35726cd82e3003675d8ba432efe68f7c4f74
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 17:46:04 2008 +0200
Fixed typo.
commit b6084cbf070bf9e78101b1088d5d6c0d852ed6dc
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 17:43:51 2008 +0200
Improved the support of the git browser.
Now the reference is always a commit as from a commit it is always possible to travel back to the corresponding tree and blobs.
commit 9a2b8e249acad9f84401846cf87bf040ffd585b3
Merge: 789c7ed... 24e8c80...
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 01:51:55 2008 +0200
Merge branch 'gitbrowser'
commit 789c7ed43d2b551ba9de97dc8af87cb8d6fa208c
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 01:51:08 2008 +0200
Take into account if in one branch but listing another.
Need to check how this is working on a bar repository.
commit 24e8c80dfbd358710464cda0e5570655d5f200c6
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 01:37:43 2008 +0200
Updated the docstring.
commit c915f8fccfc20a1a491bb88dd7848005dc1641ff
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sun Jul 27 01:31:10 2008 +0200
Added the changelog and fixed the source browser.
The source browser is normally a little bit more robust.
commit f57a0ec08bfbaa830f4f7fb39f1f7e39d400ecb3
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sat Jul 26 20:17:18 2008 +0200
Cosmetic improvements.
commit 876e206742179ba640667430b5cad6b45c651250
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Sat Jul 26 18:42:41 2008 +0200
First work on the git browser.
commit 2e711bee8d2b7c6680d6d44cb796f2cc67c9ed68
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Jul 25 14:25:50 2008 +0200
Added a nice formatting of the issue comments.
commit 4eea3797b26cb3ab34c5b4e1b7ff5098f2284deb
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Jul 25 14:15:58 2008 +0200
Added the autocompletion of the owner and cosmetic changes.
commit e5d296d8638db9bd59a85360d80e126b901befeb
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Jul 25 11:17:56 2008 +0200
Added the Shift+w hotkey to get the working list of the user.
commit d19dbb441c86740d6a2df2501cb5875a5fc34e19
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Jul 25 11:16:18 2008 +0200
Added a hotkey tag to easily add them.
Added a new Shift+m hotkey to access the list of submitted issues.
commit cc5ec30e6a06a3c855848b907512e4b796950981
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Jul 25 10:28:35 2008 +0200
Correctly set the copyrights.
commit efbd82fccb20b0b4c9ac82777b8bdf7d83be0e40
Author: Loic d'Anterroches <titoo@users.sourceforge.net>
Date: Fri Jul 25 10:26:05 2008 +0200
Initial commit.