From d0079a334fe2b769e4f81d6bd3c7e4346a8fa2b2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 20 Jun 2022 19:27:29 +0000 Subject: search: support "patchid:" prefix (git patch-id --stable) This allows easy searching via patch-id from a git commit. Currently, abbreviations are not supported, and it seems needless to support them since AFAIK (git) doesn't generate nor resolve abbreviated patch-ids anywhere. --- t/extsearch.t | 7 ++++++- t/v2mda.t | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/extsearch.t b/t/extsearch.t index 09cbdabe..2d7375d6 100644 --- a/t/extsearch.t +++ b/t/extsearch.t @@ -314,7 +314,12 @@ if ('reindex catches missed messages') { is($new->{subject}, $eml->header('Subject'), 'new message added'); $es->{xdb}->reopen; - my $mset = $es->mset("mid:$new->{mid}"); + # git patch-id --stable search->mset("patchid:$patchid"); + is($mset->size, 1, 'patchid search works'); + + $mset = $es->mset("mid:$new->{mid}"); is($mset->size, 1, 'previously unseen, now indexed in Xapian'); ok($im->remove($eml), 'remove new message from v2 inbox'); diff --git a/t/v2mda.t b/t/v2mda.t index 3dfc569e..8f2f335d 100644 --- a/t/v2mda.t +++ b/t/v2mda.t @@ -1,7 +1,8 @@ -# Copyright (C) 2018-2021 all contributors +#!perl -w +# Copyright (C) all contributors # License: AGPL-3.0+ +use v5.10.1; use strict; -use warnings; use Test::More; use Fcntl qw(SEEK_SET); use Cwd; @@ -88,6 +89,11 @@ is($eml->as_string, $mime->as_string, 'injected message'); $pre = $ibx->search->mset_to_smsg($ibx, $pre); $post = $ibx->search->mset_to_smsg($ibx, $post); is($post->[0]->{blob}, $pre->[0]->{blob}, 'same message in both cases'); + + # git patch-id --stable search->mset("patchid:$patchid"); + is($mset->size, 1, 'patchid search works'); } done_testing(); -- cgit v1.2.3-24-ge0c7