Permalink
Browse files

* Added support for JIRA as an integrated bug-tracker.

  • Loading branch information...
1 parent 5793ad8 commit 30879603a55064fb96f23cb131d2ad24516dc4a0 sits committed Mar 29, 2010
View
@@ -7,6 +7,8 @@ Version 1.9.11
* Fixed issue where Perforce diffs created by just specifying a single tag
would not work.
+
+* Added support for JIRA as an integrated bug-tracker.
Version 1.9.10
View
@@ -517,7 +517,7 @@ sub have_vers {
my $topicbug_table =
table(name => "topicbug",
columns => [col(name=>"topicid", type=>$INT32, pk=>1),
- col(name=>"bugid", type=>$INT32, pk=>1)
+ col(name=>"bugname", type=>$VARCHAR, length=>255, pk=>1)
],
indexes => [dbindex(name=>"topicbug_tid_idx",
column_names=>["topicid"])]);
@@ -1086,6 +1086,22 @@ ($$$$)
}
$database->commit() if $user_added;
+# Migrate the topic bug table to support non-numeric bug IDs.
+if ($database->column_exists("topicbug", "bugid")) {
+ print "Detected old version of topicbug table, migrating...\n";
+ move_old_table($topicbug_table, "topicid, bugid");
+ my $insert_topicbug =
+ $dbh->prepare_cached("INSERT INTO topicbug (topicid, bugname) VALUES (?, ?)");
+ $stmt = $dbh->prepare_cached("SELECT topicid, bugid FROM topicbug_old");
+ $stmt->execute();
+ while (my ($topicid, $bugid) = $stmt->fetchrow_array()) {
+ $insert_topicbug->execute($topicid, $bugid);
+ }
+ $stmt->finish();
+ $database->commit();
+ $dbh->do('DROP TABLE topicbug_old');
+}
+
# Now generate the contents of the codestriker.pl file, with the appropriate
# configuration details set (basically, the location of the lib dir).
print "Generating cgi-bin/codestriker.pl file...\n";
View
@@ -39,7 +39,6 @@ $dbpasswd = 'cspasswd';
# system metric reports. If this remains commented out, then no
# authentication will be required, and users have full access to the
# system.
-#$admin_users = [ 'david.sitsky@gmail.com' ];
#$admin_users = [ 'david.sitsky@gmail.com', 'sits@users.sourceforge.net' ];
# "From" email address to use when sending emails relating to
@@ -411,6 +410,7 @@ $bug_db = '';
#$bug_db = 'flyspray';
#$bug_db = 'testdirector';
#$bug_db = 'mantis';
+#$bug_db = 'jira';
$bug_db = 'noconnection';
# Bugzilla database connection details.
@@ -434,6 +434,11 @@ $bug_db = 'noconnection';
#$testdirector_domain = 'DEFAULT';
#$testdirector_project = 'BPM33';
+# JIRA connection details
+#$jira_url = 'http://jira.mycompany.com';
+#$jira_username = 'codestriker';
+#$jira_password = 'passwd';
+
# The URL to the bug tracking system. The bug number is appended to the
# end of this string when URLs are generated. This can be left blank if
# there is no need for bug-tracking integration. Below are some example
@@ -15,6 +15,7 @@ use Codestriker::BugDB::FlysprayConnection;
use Codestriker::BugDB::MantisConnection;
use Codestriker::BugDB::NoConnection;
use Codestriker::BugDB::TestDirectorConnection;
+use Codestriker::BugDB::JIRAConnection;
# Factory method for retrieving a BugDBConnection object.
sub getBugDBConnection ($) {
@@ -29,6 +30,8 @@ sub getBugDBConnection ($) {
return Codestriker::BugDB::MantisConnection->get_connection();
} elsif ($dbtype eq "testdirector") {
return Codestriker::BugDB::TestDirectorConnection->get_connection();
+ } elsif ($dbtype eq "jira") {
+ return Codestriker::BugDB::JIRAConnection->get_connection();
} elsif ($dbtype =~ /^noconnect/) {
return Codestriker::BugDB::NoConnection->get_connection();
} else {
@@ -0,0 +1,50 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# sits@users.sourceforge.net
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# JIRA connection class, for appending comments to a bug report.
+
+package Codestriker::BugDB::JIRAConnection;
+
+use strict;
+use DBI;
+
+# Optional dependenct for people who don't use this module.
+eval("use JIRA::Client;");
+
+# Static method for building a database connection.
+sub get_connection($) {
+ my ($type) = @_;
+
+ # Return a connection with JIRA.
+ my $self = {};
+ $self->{jira} = JIRA::Client->new($Codestriker::jira_url, $Codestriker::jira_username,
+ $Codestriker::jira_password);
+ bless $self, $type;
+}
+
+# Method for releasing a mantis database connection.
+sub release_connection($) {
+ my ($self) = @_;
+}
+
+# Return true if the specified bugid exists in the bug database,
+# false otherwise.
+sub bugid_exists($$) {
+ my ($self, $bugid) = @_;
+
+ return defined $self->{jira}->getIssue($bugid);
+}
+
+sub update_bug($$$$$) {
+
+ my ($self, $bugid, $comment, $topic_url, $topic_state) = @_;
+
+ # Insert the note: "Codestriker topic: Author: Reviewer(s): Title: Description: "
+ $self->{jira}->addComment($bugid, $comment);
+}
+
+1;
@@ -367,7 +367,7 @@ sub _untaint_emails($$) {
sub _untaint_bug_ids($$) {
my ($self, $name) = @_;
- $self->_untaint($name, '([0-9]+[\s,;]*){1,100}');
+ $self->_untaint($name, '([A-z0-9\-]+[\s,;]*){1,100}');
}
1;
@@ -103,7 +103,7 @@ sub _insert_bug_ids($$$) {
my ($self, $dbh, $bug_ids) = @_;
my $insert_bugs =
- $dbh->prepare_cached('INSERT INTO topicbug (topicid, bugid) ' .
+ $dbh->prepare_cached('INSERT INTO topicbug (topicid, bugname) ' .
'VALUES (?, ?)');
my $success = defined $insert_bugs;
@@ -247,7 +247,7 @@ sub read($$) {
'WHERE topic.id = ? AND ' .
'topic.projectid = project.id');
my $select_bugs =
- $dbh->prepare_cached('SELECT bugid FROM topicbug WHERE topicid = ?');
+ $dbh->prepare_cached('SELECT bugname FROM topicbug WHERE topicid = ?');
my $select_participants =
$dbh->prepare_cached('SELECT type, email FROM participant ' .
'WHERE topicid = ?');
@@ -757,7 +757,7 @@ sub query($$$$$$$$$$$$$$\@\@\@) {
($database->case_insensitive_like("participant.email", $scc) .
" AND type = $Codestriker::PARTICIPANT_CC");
my $bugid_part = $sbugid eq "" ? "" :
- ("topicbug.bugid = " . $dbh->quote($sbugid));
+ ("topicbug.bugname = " . $dbh->quote($sbugid));
# Build up the state condition.
my $state_part = "";
@@ -786,7 +786,7 @@ sub query($$$$$$$$$$$$$$\@\@\@) {
my $query =
"SELECT topic.id, topic.title, topic.description, " .
"topic.author, topic.creation_ts, " .
- "topic.state, topicbug.bugid, participant.email, participant.type, " .
+ "topic.state, topicbug.bugname, participant.email, participant.type, " .
"topic.version ";
# Since Oracle < 9i can't handle LEFT OUTER JOIN, determine what tables

0 comments on commit 3087960

Please sign in to comment.