Ignore non-error, remove redundant upsertReleases call

Amolith created

Change summary

build-all.sh       | 38 ++++++++++++++++++++++++++++++++++++++
git/git.go         |  3 +++
project/project.go | 10 +---------
3 files changed, 42 insertions(+), 9 deletions(-)

Detailed changes

build-all.sh 🔗

@@ -0,0 +1,38 @@
+#!/usr/bin/env sh
+
+# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+#
+# SPDX-License-Identifier: CC0-1.0
+
+export CGO_ENABLED=0
+
+if ! git describe --tags --exact-match HEAD; then
+    echo "Not a tagged commit, refusing to build for all platforms."
+    exit 0
+fi
+
+TAG=$(git describe --tags --exact-match HEAD)
+NAME=$(basename "$(pwd)")
+
+mkdir -p "out/$TAG"
+
+while read -r LOOP_OS LOOP_ARCH; do
+    echo "Building $NAME-$LOOP_OS-$LOOP_ARCH"
+    GOOS="$LOOP_OS" GOARCH="$LOOP_ARCH" go build -ldflags="-s -w" -o "out/$TAG/$NAME-$LOOP_OS-$LOOP_ARCH" ./cmd
+done <<EOF
+darwin amd64
+freebsd 386
+freebsd amd64
+freebsd arm
+freebsd arm64
+linux 386
+linux amd64
+linux arm
+linux arm64
+linux ppc64le
+linux riscv64
+netbsd amd64
+openbsd amd64
+openbsd arm64
+windows amd64
+EOF

git/git.go 🔗

@@ -119,6 +119,9 @@ func minimalClone(url string) (r *git.Repository, err error) {
 			Depth:      1,
 			Tags:       git.AllTags,
 		})
+		if errors.Is(err, git.NoErrAlreadyUpToDate) {
+			return r, nil
+		}
 		return r, err
 	} else if !errors.Is(err, git.ErrRepositoryNotExists) {
 		return nil, err

project/project.go 🔗

@@ -50,15 +50,7 @@ func GetReleases(dbConn *sql.DB, mu *sync.Mutex, proj Project) (Project, error)
 	}
 
 	if len(ret) == 0 {
-		proj, err = fetchReleases(dbConn, mu, proj)
-		if err != nil {
-			return proj, err
-		}
-		err = upsertReleases(dbConn, mu, proj.ID, proj.Releases)
-		if err != nil {
-			return proj, err
-		}
-		return proj, nil
+		return fetchReleases(dbConn, mu, proj)
 	}
 
 	for _, row := range ret {