mirror of
https://git.sr.ht/~rjarry/aerc
synced 2025-07-06 19:30:22 +02:00

Add an auto-switch option that changes the project of the patch manager based on the subject line of a message if it contains a '[PATCH <project>]' segment. A subject line with '[PATCH aerc v2]' would switch to the 'aerc' project if that project is available in the patch manager. The auto switching can be activated per account by adding 'pama-auto-switch = true' to your account config. Implements: https://todo.sr.ht/~rjarry/aerc/226 Changelog-added: Auto-switch projects based on the message subject for the :patch command. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
67 lines
1.1 KiB
Go
67 lines
1.1 KiB
Go
package pama_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.sr.ht/~rjarry/aerc/lib/pama"
|
|
)
|
|
|
|
func TestFromSubject(t *testing.T) {
|
|
tests := []struct {
|
|
s string
|
|
want string
|
|
}{
|
|
{
|
|
s: "[PATCH aerc] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[PATCH aerc v2] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[PATCH aerc 1/2] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[Patch aerc] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[patch aerc] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[RFC PATCH aerc] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[DRAFT PATCH aerc] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "RE: [PATCH aerc v1] pama: new patch",
|
|
want: "aerc",
|
|
},
|
|
{
|
|
s: "[PATCH] pama: new patch",
|
|
want: "",
|
|
},
|
|
{
|
|
s: "just a subject line",
|
|
want: "",
|
|
},
|
|
{
|
|
s: "just a subject line with unrelated [asdf aerc v1]",
|
|
want: "",
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
got := pama.FromSubject(test.s)
|
|
if got != test.want {
|
|
t.Errorf("failed to get name from '%s': "+
|
|
"got '%s', want '%s'", test.s, got, test.want)
|
|
}
|
|
}
|
|
}
|