[PATCH] Add support for stripping a subject prefix that's different from linkname

Sascha Silbe sascha-pgp at silbe.org
Fri Nov 26 21:57:36 EST 2010

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

Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
 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:
-	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 @@
+ALTER TABLE patchwork_project ADD COLUMN subjectprefix varchar(255) NULL;

More information about the Patchwork mailing list