aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-05-24 17:37:07 -0400
committerXe Iaso <me@xeiaso.net>2024-05-24 17:37:07 -0400
commit6de8ae1cd17dfff569ac82e07204c48bfe2e3a62 (patch)
treeabaedee2a9a6b1254c4375186b75f3c1e335792a /internal
parentfa4e3a34bb7474cada1ee748d9e7ed9fc2cda3f5 (diff)
downloadxesite-6de8ae1cd17dfff569ac82e07204c48bfe2e3a62.tar.xz
xesite-6de8ae1cd17dfff569ac82e07204c48bfe2e3a62.zip
internal/lume: allow rebuilds when git is happy
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'internal')
-rw-r--r--internal/lume/lume.go10
-rw-r--r--internal/passwdmiddleware.go15
2 files changed, 23 insertions, 2 deletions
diff --git a/internal/lume/lume.go b/internal/lume/lume.go
index a575d2b..aa84abe 100644
--- a/internal/lume/lume.go
+++ b/internal/lume/lume.go
@@ -4,6 +4,7 @@ import (
"archive/zip"
"context"
"encoding/json"
+ "errors"
"expvar"
"fmt"
"html/template"
@@ -251,8 +252,13 @@ func (f *FS) Update(ctx context.Context) error {
ReferenceName: plumbing.NewBranchReferenceName(f.opt.Branch),
})
if err != nil {
- updateErrors.Add(1)
- return err
+ switch {
+ case errors.Is(err, git.NoErrAlreadyUpToDate):
+ slog.Debug("already up to date")
+ default:
+ updateErrors.Add(1)
+ return err
+ }
}
err = wt.Checkout(&git.CheckoutOptions{
diff --git a/internal/passwdmiddleware.go b/internal/passwdmiddleware.go
new file mode 100644
index 0000000..8fa511a
--- /dev/null
+++ b/internal/passwdmiddleware.go
@@ -0,0 +1,15 @@
+package internal
+
+import "net/http"
+
+func PasswordMiddleware(username, password string, next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ user, pass, ok := r.BasicAuth()
+ if !ok || user != username || pass != password {
+ http.Error(w, "Unauthorized", http.StatusUnauthorized)
+ return
+ }
+
+ next.ServeHTTP(w, r)
+ })
+}