feat: add private tag to private repos on tailnet

Signed-off-by: jolheiser <git@jolheiser.com>
tui
jolheiser 2024-07-26 15:01:38 -05:00
parent ff1eaf72bf
commit ad26f8c949
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View File

@ -30,9 +30,13 @@ func (rh repoHandler) index(w http.ResponseWriter, r *http.Request) error {
if err != nil { if err != nil {
return httperr.Error(err) return httperr.Error(err)
} }
if repo.Meta.Private && !rh.s.ShowPrivate { if repo.Meta.Private {
if !rh.s.ShowPrivate {
continue continue
} }
repo.Meta.Tags = append(repo.Meta.Tags, "private")
}
if tagFilter != "" && !slices.Contains(repo.Meta.Tags, strings.ToLower(tagFilter)) { if tagFilter != "" && !slices.Contains(repo.Meta.Tags, strings.ToLower(tagFilter)) {
continue continue
} }

View File

@ -26,9 +26,12 @@ func (rh repoHandler) repoMiddleware(next http.Handler) http.Handler {
} }
return httperr.Status(err, httpErr) return httperr.Status(err, httpErr)
} }
if repo.Meta.Private && !rh.s.ShowPrivate { if repo.Meta.Private {
if !rh.s.ShowPrivate {
return httperr.Status(errors.New("could not get git repo"), http.StatusNotFound) return httperr.Status(errors.New("could not get git repo"), http.StatusNotFound)
} }
repo.Meta.Tags = append(repo.Meta.Tags, "private")
}
r = r.WithContext(context.WithValue(r.Context(), repoCtxKey, repo)) r = r.WithContext(context.WithValue(r.Context(), repoCtxKey, repo))
next.ServeHTTP(w, r) next.ServeHTTP(w, r)
return nil return nil