~sircmpwn/sr.ht-dev

hub.sr.ht: Submit build for prefix-less patches if project has a single repo v1 PROPOSED

Simon Ser: 1
 Submit build for prefix-less patches if project has a single repo

 1 files changed, 11 insertions(+), 9 deletions(-)
#550099 alpine.yml success
#550100 archlinux.yml failed
#550101 debian.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/23933/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH hub.sr.ht] Submit build for prefix-less patches if project has a single repo Export this patch

When a hub project has a single repository configured, trigger
builds for patch submissions with that repository.
---
 hubsrht/builds.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/hubsrht/builds.py b/hubsrht/builds.py
index 8a79160b2ae3..c40b0b7d6d0f 100644
--- a/hubsrht/builds.py
+++ b/hubsrht/builds.py
@@ -20,16 +20,18 @@ def submit_patchset(ml, payload):
    subject = payload["subject"]

    prefix = payload["prefix"]
    if not prefix:
        # TODO: More sophisticated matching is possible
        # - test if patch is applicable to a repo; see the following:
        #   https://github.com/libgit2/pygit2/pull/1019
        # Will be useful for mailing lists shared by many repositories
        return None
    # TODO: More sophisticated matching is possible
    # - test if patch is applicable to a repo; see the following:
    #   https://github.com/libgit2/pygit2/pull/1019
    # Will be useful for mailing lists shared by many repositories
    if prefix:
        repo = (SourceRepo.query
                .filter(SourceRepo.project_id == project.id)
                .filter(func.lower(SourceRepo.name) == prefix.lower())).one_or_none()
    else:
        repo = (SourceRepo.query
                .filter(SourceRepo.project_id == project.id)).one_or_none()

    repo = (SourceRepo.query
            .filter(SourceRepo.project_id == project.id)
            .filter(func.lower(SourceRepo.name) == prefix.lower())).one_or_none()
    if not repo:
        return None
    if repo.repo_type != RepoType.git:
-- 
2.32.0
builds.sr.ht
hub.sr.ht/patches: FAILED in 1m57s

[Submit build for prefix-less patches if project has a single repo][0] from [Simon Ser][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/23933
[1]: mailto:contact@emersion.fr

✗ #550100 FAILED  hub.sr.ht/patches/archlinux.yml https://builds.sr.ht/~sircmpwn/job/550100
✓ #550101 SUCCESS hub.sr.ht/patches/debian.yml    https://builds.sr.ht/~sircmpwn/job/550101
✓ #550099 SUCCESS hub.sr.ht/patches/alpine.yml    https://builds.sr.ht/~sircmpwn/job/550099
The issue here is if one mailing list is shared between many projects.
We should be able to detect this also with a slightly different SQL
query.