# HG changeset patch # User Vincent Tondellier # Date 1689627162 -7200 # Node ID 26ba2717da6ef0bf7bfae738d93d8213199fd92d # Parent 42a4a2f8c790fbd5795e56503f2e38a5292d629c Allow matching filelink on partial url paths diff -r 42a4a2f8c790 -r 26ba2717da6e lib/CrashTest/Plugin/StackFilter/FileLink.pm --- a/lib/CrashTest/Plugin/StackFilter/FileLink.pm Mon Jul 17 22:51:43 2023 +0200 +++ b/lib/CrashTest/Plugin/StackFilter/FileLink.pm Mon Jul 17 22:52:42 2023 +0200 @@ -36,21 +36,36 @@ my ($self, $scm, $repo) = @_; my $linkconf = "$scm:$repo"; - if(defined($self->{_template_cache}->{$linkconf})) { + if(exists($self->{_template_cache}->{$linkconf})) { return $self->{_template_cache}->{$linkconf}; } - my $template = $self->config->{WebInterface}->{ScmLinks}->{$linkconf}; + my $template = $self->config->{WebInterface}->{ScmLinks}->{$linkconf} // undef; + + # try striping repo path elements until a match + if(!defined($template)) { + my $rpath = $repo; + while($rpath =~ m:^(.+)/[^/]+[/]?$:xms) { + $rpath = $1; + $linkconf = "$scm:$rpath"; + $template = $self->config->{WebInterface}->{ScmLinks}->{$linkconf} // undef; + if(defined($template)) { + # keep full repo in cache (avoid loop) + $linkconf = "$scm:$repo"; + break; + } + } + } # try the generic repository type if(!defined($template)) { $linkconf = $scm; - if(defined($self->{_template_cache}->{$linkconf})) { + if(exists($self->{_template_cache}->{$linkconf})) { return $self->{_template_cache}->{$linkconf}; } - $template = $self->config->{WebInterface}->{ScmLinks}->{$linkconf}; + $template = $self->config->{WebInterface}->{ScmLinks}->{$linkconf} // undef; } - return undef if !defined($template); + return if !defined($template); $self->app->log->debug("Building template for $linkconf");