Merge pull request #1043 from DeterminateSystems/perl-warnings

Fixup Perl warnings around undefined variables
This commit is contained in:
Graham Christensen 2021-10-20 10:48:05 -04:00 committed by GitHub
commit f0d0358ee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 12 deletions

View file

@ -10,7 +10,7 @@ use Hydra::Helper::CatalystUtils;
sub isEnabled { sub isEnabled {
my ($self) = @_; my ($self) = @_;
return $self->{config}->{enable_bitbucket_status} == 1; return ($self->{config}->{enable_bitbucket_status} // 0) == 1;
} }
sub toBitBucketState { sub toBitBucketState {

View file

@ -53,7 +53,7 @@ sub buildFinished {
my $covTarball; my $covTarball;
opendir my $tarballs_handle, $tarballs or die; opendir my $tarballs_handle, $tarballs or die;
while (my $file = readdir $tarballshandle) { while (my $file = readdir $tarballs_handle) {
next unless $file =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/; next unless $file =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/;
$covTarball = "$tarballs/$file"; last; $covTarball = "$tarballs/$file"; last;
} }

View file

@ -12,7 +12,7 @@ use Hydra::Helper::Email;
sub isEnabled { sub isEnabled {
my ($self) = @_; my ($self) = @_;
return $self->{config}->{email_notification} == 1; return ($self->{config}->{email_notification} // 0) == 1;
} }
my $template = <<EOF; my $template = <<EOF;

View file

@ -34,7 +34,7 @@ sub _parseValue {
my $start_options = 3; my $start_options = 3;
# if deepClone has "=" then is considered an option # if deepClone has "=" then is considered an option
# and not the enabling of deepClone # and not the enabling of deepClone
if (index($deepClone, "=") != -1) { if (defined($deepClone) && index($deepClone, "=") != -1) {
undef $deepClone; undef $deepClone;
$start_options = 2; $start_options = 2;
} }

View file

@ -97,8 +97,8 @@ sub _iterate {
} }
sub fetchInput { sub fetchInput {
my ($self, $type, $name, $value, $project, $jobset) = @_; my ($self, $input_type, $name, $value, $project, $jobset) = @_;
return undef if $type ne "github_refs"; return undef if $input_type ne "github_refs";
my ($owner, $repo, $type, $fut, $prefix) = split ' ', $value; my ($owner, $repo, $type, $fut, $prefix) = split ' ', $value;
die "type field is neither 'heads' nor 'tags', but '$type'" die "type field is neither 'heads' nor 'tags', but '$type'"

View file

@ -21,11 +21,18 @@ sub isEnabled {
} }
my $client; my $client;
my %compressors = ( my %compressors = ();
xz => "| $Nix::Config::xz",
bzip2 => "| $Nix::Config::bzip2", $compressors{"none"} = "";
none => ""
); if (defined($Nix::Config::bzip2)) {
$compressors{"bzip2"} = "| $Nix::Config::bzip2",
}
if (defined($Nix::Config::xz)) {
$compressors{"xz"} = "| $Nix::Config::xz",
}
my $lockfile = Hydra::Model::DB::getHydraPath . "/.hydra-s3backup.lock"; my $lockfile = Hydra::Model::DB::getHydraPath . "/.hydra-s3backup.lock";
sub buildFinished { sub buildFinished {

View file

@ -567,7 +567,7 @@ sub checkJobsetWrapped {
my $inputInfo = {}; my $inputInfo = {};
if ($jobsetsJobset) { if ($jobsetsJobset) {
my @declInputs = fetchInput($plugins, $db, $project, $jobset, "decl", $project->decltype, $project->declvalue, 0); my @declInputs = fetchInput($plugins, $db, $project, $jobset, "decl", $project->decltype, $project->declvalue, 0);
my $declInput = @declInputs[0] or die "cannot find the input containing the declarative project specification\n"; my $declInput = $declInputs[0] or die "cannot find the input containing the declarative project specification\n";
die "multiple alternatives for the input containing the declarative project specification are not supported\n" die "multiple alternatives for the input containing the declarative project specification are not supported\n"
if scalar @declInputs != 1; if scalar @declInputs != 1;
my $declFile = $declInput->{storePath} . "/" . $project->declfile; my $declFile = $declInput->{storePath} . "/" . $project->declfile;