Cleaned up code a bit.
[clearscm.git] / JIRA / lib / BugzillaUtils.pm
index 899f506..7a825c2 100644 (file)
@@ -91,10 +91,10 @@ sub openBugzilla (;$$$$) {
   $dbhost //= 'jira-dev';
   $dbname //= 'bugzilla';
   $dbuser //= 'adefaria';
-  $dbpass //= 'reader';
-  
+  $dbpass //= '********';
+
   $main::log->msg ("Connecting to Bugzilla ($dbuser\@$dbhost)");
-  
+
   $bugzilla = DBI->connect (
     "DBI:mysql:$dbname:$dbhost",
     $dbuser,
@@ -103,7 +103,7 @@ sub openBugzilla (;$$$$) {
       RaiseError => 1,
     },
   );
-  
+
   _checkDBError 'Unable to execute statement', 'Connect';
 
   return $bugzilla;
@@ -111,16 +111,16 @@ sub openBugzilla (;$$$$) {
 
 sub getBug ($;@) {
   my ($bugid, @fields) = @_;
-  
+
   push @fields, 'short_desc' unless @fields;
-  
+
   my $statement = 'select ' . join (',', @fields) .
                   " from bugs where bug_id = $bugid";
-                  
+
   my $sth = $bugzilla->prepare ($statement);
 
   _checkDBError 'Unable to prepare statement', $statement;
-  
+
   _checkDBError 'Unable to execute statement', $statement;
 
   $sth->execute;
@@ -130,7 +130,7 @@ sub getBug ($;@) {
 
 sub getBugComments ($) {
   my ($bugid) = @_;
-  
+
   my $statement = <<"END";
 select 
   bug_id, 
@@ -144,17 +144,17 @@ where
   who    = userid and
   bug_id = $bugid 
 END
-  
+
   my $sth = $bugzilla->prepare ($statement);
-  
+
   _checkDBError 'Unable to prepare statement', $statement;
 
   $sth->execute;
-  
+
   _checkDBError 'Unable to execute statement', $statement;
-  
+
   my @comments;
-  
+
   while (my $comment = $sth->fetchrow_hashref) {
     my $commentText = <<"END";
 The following comment was entered by [~$comment->{username}] on $comment->{bug_when}:
@@ -164,75 +164,75 @@ END
 
     push @comments, $commentText;
   } # while
-  
+
   return \@comments;
 } # getBugComments
 
 sub getRelationships ($$$$@) {
   my ($table, $returnField, $testField, $relationshipType, @bugs) = @_;
-  
+
   $main::log->msg ("Getting $relationshipType");
-  
+
   my $statement = "select $returnField from $table where $table.$testField = ?";
 
   my $sth = $bugzilla->prepare ($statement);
 
   _checkDBError 'Unable to prepare statement', $statement;
-  
+
   my %relationships;
 
   my %bugmap;
-  
+
   map {$bugmap{$_} = 1} @bugs unless %bugmap;
-      
+
   for my $bugid (@bugs) {
     $sth->execute ($bugid);
-    
+
     _checkDBError 'Unable to exit statement', $statement;
-    
+
     my $result = JIRAUtils::findIssue ($bugid, %bugmap);
-    
+
     if ($result =~ /^Unable/) {
       $main::log->warn ($result);
-      
+
       $main::total{'Missing JIRA Issues'}++;
-      
+
       undef $result;
     } elsif ($result =~ /^Future/) {
       $main::total{'Future JIRA Issues'}++;
-      
+
       undef $result;
     } # if
-    
+
     my $jiraIssue = $result;
     my $key       = $jiraIssue || $bugid;
 
     my @relationships;
     my $relations = $sth->fetchall_arrayref;
     my @relations;
-    
+
     map {push @relations, $_->[0]} @$relations;
-    
+
     for my $relation (@relations) {
       $jiraIssue = JIRAUtils::findIssue ($relation);
-      
+
       if ($jiraIssue =~ /^Unable/ || $jiraIssue =~ /^Future/) {
         $main::log->warn ($jiraIssue);
 
         $main::total{'Missing JIRA Issues'}++ if $jiraIssue =~ /^Unable/;
         $main::total{'Future JIRA Issues'}++  if $jiraIssue =~ /^Future/;
-        
+
         push @relationships, $relation;
       } else {
         push @relationships, $jiraIssue;
       } # if
     } # for
-      
+
     push @{$relationships{$key}}, @relationships if @relationships;
   } # for
-  
+
   $main::total{$relationshipType} = keys %relationships;
-  
+
   return \%relationships;
 } # getRelationships
 
@@ -250,7 +250,7 @@ sub getDependencies (@) {
 
 sub getBlockers (@) {
   my (@bugs) = @_;
-  
+
   return getRelationships (
     'dependencies', 
     'blocked', 
@@ -274,7 +274,7 @@ sub getDuplicates (@) {
 
 sub getRelated (@) {
   my (@bugs) = @_;
-  
+
   return getRelationships (
     'bug_see_also', 
     'value', 
@@ -286,7 +286,7 @@ sub getRelated (@) {
 
 sub getWatchers ($) {
   my ($bugid) = @_;
-  
+
   my $statement = <<"END";
 select 
   profiles.login_name