From 979b606b1ea08861d3b1aff61b25c49b13f03884 Mon Sep 17 00:00:00 2001 From: unilock Date: Mon, 15 Apr 2024 19:18:05 -0400 Subject: [PATCH] github: check + fail if there are no assets matching regex Signed-off-by: unilock --- github/install.go | 4 ++++ github/updater.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/github/install.go b/github/install.go index ea862f4..e47ca62 100644 --- a/github/install.go +++ b/github/install.go @@ -134,6 +134,10 @@ func installRelease(repo Repo, release Release, regex string, pack core.Pack) er } } + if len(files) == 0 { + return errors.New("release doesn't have any assets matching regex") + } + if len(files) > 1 { // TODO: also print file names return errors.New("release has more than one asset matching regex") diff --git a/github/updater.go b/github/updater.go index 9f66cb8..c970961 100644 --- a/github/updater.go +++ b/github/updater.go @@ -68,6 +68,11 @@ func (u ghUpdater) CheckUpdate(mods []*core.Mod, pack core.Pack) ([]core.UpdateC } } + if len(newFiles) == 0 { + results[i] = core.UpdateCheck{Error: errors.New("release doesn't have any assets matching regex")} + continue + } + if len(newFiles) > 1 { // TODO: also print file names results[i] = core.UpdateCheck{Error: errors.New("release has more than one asset matching regex")}