X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=JIRA%2Flib%2FBugzillaUtils.pm;h=7a825c2e8f490ce05d08ee80176f00c8b8cc375a;hb=fa5ce145aa7736440b3a8f81bf4e672d8fe6cd70;hp=899f506c323397d178eef116a4d4ebe646638b03;hpb=b5be44d98985746b6319309d8272b297674b540c;p=clearscm.git diff --git a/JIRA/lib/BugzillaUtils.pm b/JIRA/lib/BugzillaUtils.pm index 899f506..7a825c2 100644 --- a/JIRA/lib/BugzillaUtils.pm +++ b/JIRA/lib/BugzillaUtils.pm @@ -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