From patchwork Fri Nov 26 06:10:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Silbe X-Patchwork-Id: 73179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 7E178B70E6 for ; Sat, 27 Nov 2010 01:13:49 +1100 (EST) X-Greylist: delayed 577 seconds by postgrey-1.32 at bilbo; Fri, 26 Nov 2010 17:20:27 EST Received: from sunjammer.sugarlabs.org (sunjammer.sugarlabs.org [140.186.70.53]) by ozlabs.org (Postfix) with ESMTP id 81AEFB70D4 for ; Fri, 26 Nov 2010 17:20:26 +1100 (EST) Received: by sunjammer.sugarlabs.org (Postfix, from userid 708) id D19CE1206C4; Fri, 26 Nov 2010 01:10:45 -0500 (EST) From: Sascha Silbe To: patchwork@lists.ozlabs.org Subject: [PATCH] Add support for stripping a subject prefix that's different from linkname Date: Fri, 26 Nov 2010 01:10:36 -0500 Message-Id: <1290751836-2772-1-git-send-email-sascha-pgp@silbe.org> X-Mailer: git-send-email 1.7.0.4 X-Mailman-Approved-At: Sat, 27 Nov 2010 01:13:47 +1100 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Sascha Silbe List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Strip off Project.subjectprefix from the subject of incoming patches. Will fall back to Project.linkname if subjectprefix is unset or empty. At Sugar Labs, we have a mailing list called sugar-devel (using its name as subject prefix) where patches for several repositories get sent to, including sugar and sugar-toolkit. In order to distinguish between the repositories, patch submitters include the repository name as a subject prefix (e.g. "[PATCH v2 sugar]"). Since the link name for the project is set to just "sugar", Patchwork would leave the list prefix ([sugar-devel]) as part of the patch name, but remove the repository name (... sugar]). By allowing to override the subject prefix, we can get Patchwork to strip the list name and leave the repository name alone. --- apps/patchwork/bin/parsemail.py | 3 ++- apps/patchwork/models.py | 1 + lib/sql/migration/007-project-subjectprefix.sql | 3 +++ 3 files changed, 6 insertions(+), 1 deletions(-) diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py index 68bd94c..2e70e9a 100755 --- a/apps/patchwork/bin/parsemail.py +++ b/apps/patchwork/bin/parsemail.py @@ -171,7 +171,8 @@ def find_content(project, mail): if patchbuf: mail_headers(mail) - name = clean_subject(mail.get('Subject'), [project.linkname]) + prefixes = [project.subjectprefix or project.linkname] + name = clean_subject(mail.get('Subject'), prefixes) patch = Patch(name = name, content = patchbuf, date = mail_date(mail), headers = mail_headers(mail)) diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py index 7653e6c..7e96a7c 100644 --- a/apps/patchwork/models.py +++ b/apps/patchwork/models.py @@ -64,6 +64,7 @@ class Project(models.Model): name = models.CharField(max_length=255, unique=True) listid = models.CharField(max_length=255, unique=True) listemail = models.CharField(max_length=200) + subjectprefix = models.CharField(max_length=255, null=True, blank=True) def __str__(self): return self.name diff --git a/lib/sql/migration/007-project-subjectprefix.sql b/lib/sql/migration/007-project-subjectprefix.sql new file mode 100644 index 0000000..c02102f --- /dev/null +++ b/lib/sql/migration/007-project-subjectprefix.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE patchwork_project ADD COLUMN subjectprefix varchar(255) NULL; +COMMIT;