Skip to content

Commit

Permalink
feat: add String method to visibility (#276)
Browse files Browse the repository at this point in the history
This allows templates that directly use `Private`, for example, to show a string rather than an int.

Signed-off-by: jolheiser <[email protected]>
  • Loading branch information
jolheiser committed May 10, 2024
1 parent 88f0f6e commit 6836ded
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions internal/db/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package db

import (
"fmt"
"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/dustin/go-humanize"
"github.com/rs/zerolog/log"
"github.com/thomiceli/opengist/internal/index"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/dustin/go-humanize"
"github.com/rs/zerolog/log"
"github.com/thomiceli/opengist/internal/git"
"github.com/thomiceli/opengist/internal/index"
"gorm.io/gorm"
)

Expand All @@ -24,6 +24,19 @@ const (
PrivateVisibility
)

func (v Visibility) String() string {
switch v {
case PublicVisibility:
return "public"
case UnlistedVisibility:
return "unlisted"
case PrivateVisibility:
return "private"
default:
return "???"
}
}

func (v Visibility) Next() Visibility {
switch v {
case PublicVisibility:
Expand Down

0 comments on commit 6836ded

Please sign in to comment.