From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS24940 159.69.0.0/16 X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id AF5F81F670 for ; Sun, 24 Oct 2021 21:43:49 +0000 (UTC) From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=t-8ch.de; s=mail; t=1635111826; bh=pvxK2Eb58XJTpSDRqozXyJNiJ7Ne8OBF2RhBnyXcGnM=; h=From:To:Cc:Subject:Date:From; b=DVMX7VVgzTLDPMqkHNmjipkVUyo0MobCA/+FQaPR+njzh7Lr0mmbX3QXyP8Wqi03L B/sH61m/Q/olbateTLgDbNWxqWlbqnNvljX0qbnXQPUfD1xO5pYelJCjJY1eJrNX86 tTQpl8Z8/LbVjqqLt6TnvSJDwJuqvnazlGkSZh14= To: meta@public-inbox.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PATCH 1/3] t/watch_maildir: support non-master default branch Date: Sun, 24 Oct 2021 23:43:35 +0200 Message-Id: <20211024214337.161779-1-thomas@t-8ch.de> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --- t/watch_maildir.t | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/t/watch_maildir.t b/t/watch_maildir.t index 6399fb7c..e0719f54 100644 --- a/t/watch_maildir.t +++ b/t/watch_maildir.t @@ -15,6 +15,7 @@ use_ok 'PublicInbox::Watch'; use_ok 'PublicInbox::Emergency'; my $cfgpfx = "publicinbox.test"; my $addr = 'test-public@example.com'; +my $default_branch = PublicInbox::Import::default_branch; PublicInbox::Import::init_bare($git_dir); my $msg = <new($cfg_path); PublicInbox::Watch->new($cfg)->scan('full'); my $git = PublicInbox::Git->new($git_dir); -my @list = $git->qx(qw(rev-list refs/heads/master)); +my @list = $git->qx('rev-list', $default_branch); is(scalar @list, 1, 'one revision in rev-list'); my $write_spam = sub { @@ -80,9 +81,9 @@ my $write_spam = sub { $write_spam->(); is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam'); PublicInbox::Watch->new($cfg)->scan('full'); -@list = $git->qx(qw(rev-list refs/heads/master)); +@list = $git->qx('rev-list', $default_branch); is(scalar @list, 2, 'two revisions in rev-list'); -@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master)); +@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch); is(scalar @list, 0, 'tree is empty'); is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam'); @@ -94,7 +95,7 @@ the body of a message to majordomo\@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html\n); PublicInbox::Emergency->new($maildir)->prepare(\$msg); PublicInbox::Watch->new($cfg)->scan('full'); - @list = $git->qx(qw(ls-tree -r --name-only refs/heads/master)); + @list = $git->qx('ls-tree', '-r', '--name-only', $default_branch); is(scalar @list, 1, 'tree has one file'); my $mref = $git->cat_file('HEAD:'.$list[0]); like($$mref, qr/something\n\z/s, 'message scrubbed on import'); @@ -102,9 +103,9 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n); is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam'); $write_spam->(); PublicInbox::Watch->new($cfg)->scan('full'); - @list = $git->qx(qw(ls-tree -r --name-only refs/heads/master)); + @list = $git->qx('ls-tree', '-r', '--name-only', $default_branch); is(scalar @list, 0, 'tree is empty'); - @list = $git->qx(qw(rev-list refs/heads/master)); + @list = $git->qx('rev-list', $default_branch); is(scalar @list, 4, 'four revisions in rev-list'); is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam'); } @@ -120,7 +121,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n); local $SIG{__WARN__} = sub {}; # quiet spam check warning PublicInbox::Watch->new($cfg)->scan('full'); } - @list = $git->qx(qw(ls-tree -r --name-only refs/heads/master)); + @list = $git->qx('ls-tree', '-r', '--name-only', $default_branch); is(scalar @list, 0, 'tree has no files spamc checked'); is(unlink(glob("$maildir/new/*")), 1); } @@ -132,16 +133,16 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n); local $ENV{PATH} = $main_path; PublicInbox::Emergency->new($maildir)->prepare(\$msg); $cfg->{'publicinboxwatch.spamcheck'} = 'spamc'; - @list = $git->qx(qw(ls-tree -r --name-only refs/heads/master)); + @list = $git->qx('ls-tree', '-r', '--name-only', $default_branch); PublicInbox::Watch->new($cfg)->scan('full'); - @list = $git->qx(qw(ls-tree -r --name-only refs/heads/master)); + @list = $git->qx('ls-tree', '-r', '--name-only', $default_branch); is(scalar @list, 1, 'tree has one file after spamc checked'); # XXX: workaround some weird caching/memoization in cat-file, # shouldn't be an issue in real-world use, though... $git = PublicInbox::Git->new($git_dir); - my $mref = $git->cat_file('refs/heads/master:'.$list[0]); + my $mref = $git->cat_file($default_branch.':'.$list[0]); like($$mref, qr/something\n\z/s, 'message scrubbed on import'); } base-commit: f658918dcc5200b563beea6e1ea3411e89726cb4 -- 2.33.1