Control: tags -1 + patch
On Tue, 18 May 2010 22:56:30 +0200 Stefano Rivera wrote:
> While Usertags can be set on submission (as described in Bug #327591),
> attempting to set tags for different users fails.
I have implemented support for this in an MR and attached patches:
https://salsa.debian.org/debbugs-team/debbugs/-/merge_requests/7
--
bye,
pabs
https://wiki.debian.org/PaulWise
From 8feded3eb11818df22688902ceca65ab31e50d37 Mon Sep 17 00:00:00 2001
From: Paul Wise
Date: Sun, 28 Feb 2021 09:59:52 +0800
Subject: [PATCH 1/2] Fix pluralising the Tag/Usertag headers
The match was on the lowercase version header names but
the lowercasing happened after the header name match.
---
scripts/process | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/process b/scripts/process
index 265bd58..1f40901 100755
--- a/scripts/process
+++ b/scripts/process
@@ -234,9 +234,9 @@ for my $phline (@bodylines)
my ($fn, $fv) = ($1, $2);
$fv =~ s/\s*$//;
# pluralize tag/usertag
+$fn = lc $fn;
$fn = $fn.'s' if $fn =~ /^(?:tag|usertag)$/;
print {$debugfh} ">$fn|$fv|\n";
-$fn = lc $fn;
if ($fn =~ /^control$/) {
push @control_bits,$fv;
} else {
--
2.30.1
From 6d3840567049f47c2157c7c373fd683aca9bbe9e Mon Sep 17 00:00:00 2001
From: Paul Wise
Date: Sun, 28 Feb 2021 10:40:06 +0800
Subject: [PATCH 2/2] Add support for setting usertags for multiple users in
new bugs
Store the user/usertags pseudo-headers separately to the others
and then later process them after the new bug has been created.
Implements: https://bugs.debian.org/582171
---
scripts/process | 63 -
1 file changed, 36 insertions(+), 27 deletions(-)
diff --git a/scripts/process b/scripts/process
index 1f40901..f33ebec 100755
--- a/scripts/process
+++ b/scripts/process
@@ -220,6 +220,7 @@ if (@bodylines and $bodylines[0] =~ /^-BEGIN PGP SIGNED/) {
#psuedoheaders
my %pheader;
my @control_bits;
+my @usertag_bits;
# extract pseudo-headers
for my $phline (@bodylines)
{
@@ -239,9 +240,12 @@ for my $phline (@bodylines)
print {$debugfh} ">$fn|$fv|\n";
if ($fn =~ /^control$/) {
push @control_bits,$fv;
+} elsif ($fn =~ /^(?:user|usertags)$/) {
+ $fv = lc $fv;
+ push @usertag_bits, [$fn, $fv];
} else {
# Don't lc owner or forwarded
- $fv = lc $fv unless $fn =~ /^(?:owner|forwarded|usertags|version|source-version|done)$/;
+ $fv = lc $fv unless $fn =~ /^(?:owner|forwarded|version|source-version|done)$/;
$pheader{$fn} = $fv;
}
print {$debugfh} ">$fn~$fv<\n";
@@ -696,32 +700,37 @@ if ($ref<0) { # new bug report
$data->{msgid} = $header{'message-id'};
writebug($ref, $data);
# Deal with usertags
-if (exists $pheader{usertags}) {
- my $user = $replyto;
- $user = $pheader{user} if exists $pheader{user};
- $user =~ s/,.*//;
- $user =~ s/^.*<(.*)>.*$/$1/;
- $user =~ s/[(].*[)]//;
- $user =~ s/^\s*(\S+)\s+.*$/$1/;
- if ($user ne '' and Debbugs::User::is_valid_user($user)) {
- $pheader{usertags} =~ s/(?:^\s+|\s+$)//g;
- my %user_tags;
- read_usertags(\%user_tags,$user);
- for my $tag (split /[,\s]+/, $pheader{usertags}) {
- if ($tag =~ /^[a-zA-Z0-9.+\@-]+/) {
- my %bugs_with_tag;
- @bugs_with_tag{@{$user_tags{$tag}||[]}} = (1) x @{$user_tags{$tag}||[]};
- $bugs_with_tag{$ref} = 1;
- $user_tags{$tag} = [keys %bugs_with_tag];
- }
- }
- write_usertags(\%user_tags,$user);
- }
- else {
- $brokenness .= fill_template('mail/invalid_user',
- {user => $user}
- );
- }
+my $current_user = $replyto;
+for my $field (@usertags_bits) {
+my ($name, $value) = @$field;
+if ($name eq 'user') {
+my $user = $value;
+$user =~ s/,.*//;
+$user =~ s/^.*<(.*)>.*$/$1/;
+$user =~ s/[(].*[)]//;
+$user =~ s/^\s*(\S+)\s+.*$/$1/;
+if ($user ne '' and Debbugs::User::is_valid_user($user)) {
+$current_user = $user;
+} else {
+$brokenness .= fill_template('mail/invalid_user',
+ {user => $user}
+);
+}
+}
+if ($name eq 'usertags'){
+my %user_tags;
+read_usertags(\%user_tags, $current_user);
+$value =~ s/(?:^\s+|\s+$)//g;
+for my $tag (split /[,\s]+/, $value) {
+if ($tag =~ /^[a-zA-Z0-9.+\@-]+/) {
+my %bugs_with_tag;
+@bugs_with_tag{@{$user_tags{$tag}||[]}} = (1) x @{$user_tags{$tag}||[]};
+$bugs_with_tag{$ref} = 1;
+$user_tags{$tag} = [keys %bugs_with_tag];
+}
+}
+write_usertags(\%user_tags,$current_user);
+}
}
overwritefile("db-h/$hash/$ref.report",
map {"$_\n"} @msg);
--
2.30.1
signature.asc