diff mbox

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

Message ID 1290769004-25431-1-git-send-email-sascha-pgp@silbe.org
State Superseded
Headers show

Commit Message

Sascha Silbe Nov. 26, 2010, 10:56 a.m. UTC
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.

Signed-off-by: Sascha Silbe <sascha-pgp@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(-)

Comments

Sascha Silbe Nov. 26, 2010, 3:47 p.m. UTC | #1
Excerpts from Sascha Silbe's message of Fri Nov 26 11:56:44 +0100 2010:

> Strip off Project.subjectprefix from the subject of incoming patches.
> Will fall back to Project.linkname if subjectprefix is unset or empty.
[...]

Sorry for the duplicate postings. I assumed the mails got silently
dropped (due to the envelope sender not matching my subscription
address) because they were accepted by the mail server, but I didn't
receive them back nor did they turn up in the archives. I'll be more
patient the next time. :)

Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/
diff mbox

Patch

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;