Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func runDump(ctx *cli.Context) error {
defer outFile.Close()
}

setupConsoleLogger(util.Iif(quite, log.WARN, log.INFO), log.CanColorStderr, os.Stderr)
setupConsoleLogger(util.Ternary(quite, log.WARN, log.INFO), log.CanColorStderr, os.Stderr)

setting.DisableLoggerInit()
setting.LoadSettings() // cannot access session settings otherwise
Expand Down
2 changes: 1 addition & 1 deletion cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func serveInstalled(ctx *cli.Context) error {
}
}

gtprof.EnableBuiltinTracer(util.Iif(setting.IsProd, 2000*time.Millisecond, 100*time.Millisecond))
gtprof.EnableBuiltinTracer(util.Ternary(setting.IsProd, 2000*time.Millisecond, 100*time.Millisecond))

// Set up Chi routes
webRoutes := routers.NormalRoutes()
Expand Down
4 changes: 2 additions & 2 deletions models/asymkey/ssh_key_fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func calcFingerprintNative(publicKeyContent string) (string, error) {
func CalcFingerprint(publicKeyContent string) (string, error) {
// Call the method based on configuration
useNative := setting.SSH.KeygenPath == ""
calcFn := util.Iif(useNative, calcFingerprintNative, calcFingerprintSSHKeygen)
calcFn := util.Ternary(useNative, calcFingerprintNative, calcFingerprintSSHKeygen)
fp, err := calcFn(publicKeyContent)
if err != nil {
if IsErrKeyUnableVerify(err) {
return "", err
}
return "", fmt.Errorf("CalcFingerprint(%s): %w", util.Iif(useNative, "native", "ssh-keygen"), err)
return "", fmt.Errorf("CalcFingerprint(%s): %w", util.Ternary(useNative, "native", "ssh-keygen"), err)
}
return fp, nil
}
2 changes: 1 addition & 1 deletion models/issues/issue_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
Get(&res); err != nil {
return err
}
newSorting := util.Iif(res.IssueCount > 0, res.MaxSorting+1, 0)
newSorting := util.Ternary(res.IssueCount > 0, res.MaxSorting+1, 0)
return db.Insert(ctx, &project_model.ProjectIssue{
IssueID: issue.ID,
ProjectID: newProjectID,
Expand Down
6 changes: 3 additions & 3 deletions models/issues/issue_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func IsErrIssueIsClosed(err error) bool {
}

func (err ErrIssueIsClosed) Error() string {
return fmt.Sprintf("%s [id: %d, repo_id: %d, index: %d] is already closed", util.Iif(err.IsPull, "Pull Request", "Issue"), err.ID, err.RepoID, err.Index)
return fmt.Sprintf("%s [id: %d, repo_id: %d, index: %d] is already closed", util.Ternary(err.IsPull, "Pull Request", "Issue"), err.ID, err.RepoID, err.Index)
}

func SetIssueAsClosed(ctx context.Context, issue *Issue, doer *user_model.User, isMergePull bool) (*Comment, error) {
Expand Down Expand Up @@ -84,7 +84,7 @@ func SetIssueAsClosed(ctx context.Context, issue *Issue, doer *user_model.User,
return nil, ErrIssueAlreadyChanged
}

return updateIssueNumbers(ctx, issue, doer, util.Iif(isMergePull, CommentTypeMergePull, CommentTypeClose))
return updateIssueNumbers(ctx, issue, doer, util.Ternary(isMergePull, CommentTypeMergePull, CommentTypeClose))
}

// ErrIssueIsOpen is used when reopen an opened issue
Expand All @@ -102,7 +102,7 @@ func IsErrIssueIsOpen(err error) bool {
}

func (err ErrIssueIsOpen) Error() string {
return fmt.Sprintf("%s [id: %d, repo_id: %d, index: %d] is already open", util.Iif(err.IsPull, "Pull Request", "Issue"), err.ID, err.RepoID, err.Index)
return fmt.Sprintf("%s [id: %d, repo_id: %d, index: %d] is already open", util.Ternary(err.IsPull, "Pull Request", "Issue"), err.ID, err.RepoID, err.Index)
}

func setIssueAsReopen(ctx context.Context, issue *Issue, doer *user_model.User) (*Comment, error) {
Expand Down
4 changes: 2 additions & 2 deletions models/perm/access/repo_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func (p *Permission) GetFirstUnitRepoID() int64 {
func (p *Permission) UnitAccessMode(unitType unit.Type) perm_model.AccessMode {
// if the units map contains the access mode, use it, but admin/owner mode could override it
if m, ok := p.unitsMode[unitType]; ok {
return util.Iif(p.AccessMode >= perm_model.AccessModeAdmin, p.AccessMode, m)
return util.Ternary(p.AccessMode >= perm_model.AccessModeAdmin, p.AccessMode, m)
}
// if the units map does not contain the access mode, return the default access mode if the unit exists
unitDefaultAccessMode := max(p.AccessMode, p.everyoneAccessMode[unitType])
hasUnit := slices.ContainsFunc(p.units, func(u *repo_model.RepoUnit) bool { return u.Type == unitType })
return util.Iif(hasUnit, unitDefaultAccessMode, perm_model.AccessModeNone)
return util.Ternary(hasUnit, unitDefaultAccessMode, perm_model.AccessModeNone)
}

func (p *Permission) SetUnitsWithDefaultAccessMode(units []*repo_model.RepoUnit, mode perm_model.AccessMode) {
Expand Down
2 changes: 1 addition & 1 deletion models/perm/access_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func ParseAccessMode(permission string, allowed ...AccessMode) AccessMode {
if len(allowed) == 0 {
return m
}
return util.Iif(slices.Contains(allowed, m), m, AccessModeNone)
return util.Ternary(slices.Contains(allowed, m), m, AccessModeNone)
}

// ErrInvalidAccessMode is returned when an invalid access mode is used
Expand Down
2 changes: 1 addition & 1 deletion models/project/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func NewColumn(ctx context.Context, column *Column) error {
if res.ColumnCount >= maxProjectColumns {
return fmt.Errorf("NewBoard: maximum number of columns reached")
}
column.Sorting = int8(util.Iif(res.ColumnCount > 0, res.MaxSorting+1, 0))
column.Sorting = int8(util.Ternary(res.ColumnCount > 0, res.MaxSorting+1, 0))
_, err := db.GetEngine(ctx).Insert(column)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion models/project/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *Column) moveIssuesToAnotherColumn(ctx context.Context, newColumn *Colum
return nil
}

nextSorting := util.Iif(res.IssueCount > 0, res.MaxSorting+1, 0)
nextSorting := util.Ternary(res.IssueCount > 0, res.MaxSorting+1, 0)
return db.WithTx(ctx, func(ctx context.Context) error {
for i, issue := range issues {
issue.ProjectColumnID = newColumn.ID
Expand Down
2 changes: 1 addition & 1 deletion modules/httpcache/httpcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func SetCacheControlInHeader(h http.Header, opts *CacheControlOptions) {

// "max-age=0 + must-revalidate" (aka "no-cache") is preferred instead of "no-store"
// because browsers may restore some input fields after navigate-back / reload a page.
publicPrivate := util.Iif(opts.IsPublic, "public", "private")
publicPrivate := util.Ternary(opts.IsPublic, "public", "private")
if setting.IsProd {
if opts.MaxAge == 0 {
directives = append(directives, "max-age=0", "private", "must-revalidate")
Expand Down
6 changes: 3 additions & 3 deletions modules/httplib/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func getRequestScheme(req *http.Request) string {
return s
}
if s := req.Header.Get("Front-End-Https"); s != "" {
return util.Iif(s == "on", "https", "http")
return util.Ternary(s == "on", "https", "http")
}
if s := req.Header.Get("X-Forwarded-Ssl"); s != "" {
return util.Iif(s == "on", "https", "http")
return util.Ternary(s == "on", "https", "http")
}
return ""
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func detectURLRoutePath(ctx context.Context, s string) (routePath string, ut url
cleanedPath := ""
if u.Path != "" {
cleanedPath = util.PathJoinRelX(u.Path)
cleanedPath = util.Iif(cleanedPath == ".", "", "/"+cleanedPath)
cleanedPath = util.Ternary(cleanedPath == ".", "", "/"+cleanedPath)
}
if urlIsRelative(s, u) {
if u.Path == "" {
Expand Down
2 changes: 1 addition & 1 deletion modules/markup/html_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func numericIssueLink(baseURL, class string, index int, marker string) string {

// link an HTML link
func link(href, class, contents string) string {
extra := util.Iif(class != "", ` class="`+class+`"`, "")
extra := util.Ternary(class != "", ` class="`+class+`"`, "")
return fmt.Sprintf(`<a href="%s"%s>%s</a>`, href, extra, contents)
}

Expand Down
6 changes: 3 additions & 3 deletions modules/markup/html_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
// Path determines the type of link that will be rendered. It's unknown at this point whether
// the linked item is actually a PR or an issue. Luckily it's of no real consequence because
// Gitea will redirect on click as appropriate.
issueOwner := util.Iif(ref.Owner == "", ctx.RenderOptions.Metas["user"], ref.Owner)
issueRepo := util.Iif(ref.Owner == "", ctx.RenderOptions.Metas["repo"], ref.Name)
issuePath := util.Iif(ref.IsPull, "pulls", "issues")
issueOwner := util.Ternary(ref.Owner == "", ctx.RenderOptions.Metas["user"], ref.Owner)
issueRepo := util.Ternary(ref.Owner == "", ctx.RenderOptions.Metas["repo"], ref.Name)
issuePath := util.Ternary(ref.IsPull, "pulls", "issues")
linkHref := ctx.RenderHelper.ResolveLink(util.URLJoin(issueOwner, issueRepo, issuePath, ref.Issue), LinkTypeApp)

// at the moment, only render the issue index in a full line (or simple line) as icon+title
Expand Down
8 changes: 4 additions & 4 deletions modules/markup/markdown/math/block_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (b *blockParser) Open(parent ast.Node, reader text.Reader, pc parser.Contex
node := NewBlock(dollars, pos)

// Now we need to check if the ending block is on the segment...
endBytes := giteaUtil.Iif(dollars, b.endBytesDollars, b.endBytesSquare)
endBytes := giteaUtil.Ternary(dollars, b.endBytesDollars, b.endBytesSquare)
idx := bytes.Index(line[pos+2:], endBytes)
if idx >= 0 {
// for case: "$$ ... $$ any other text" (this case will be handled by the inline parser)
Expand Down Expand Up @@ -94,16 +94,16 @@ func (b *blockParser) Continue(node ast.Node, reader text.Reader, pc parser.Cont
line, segment := reader.PeekLine()
w, pos := util.IndentWidth(line, reader.LineOffset())
if w < 4 {
endBytes := giteaUtil.Iif(block.Dollars, b.endBytesDollars, b.endBytesSquare)
endBytes := giteaUtil.Ternary(block.Dollars, b.endBytesDollars, b.endBytesSquare)
if bytes.HasPrefix(line[pos:], endBytes) && util.IsBlank(line[pos+len(endBytes):]) {
if util.IsBlank(line[pos+len(endBytes):]) {
newline := giteaUtil.Iif(line[len(line)-1] != '\n', 0, 1)
newline := giteaUtil.Ternary(line[len(line)-1] != '\n', 0, 1)
reader.Advance(segment.Stop - segment.Start - newline + segment.Padding)
return parser.Close
}
}
}
start := segment.Start + giteaUtil.Iif(pos > block.Indent, block.Indent, pos)
start := segment.Start + giteaUtil.Ternary(pos > block.Indent, block.Indent, pos)
seg := text.NewSegmentPadding(start, segment.Stop, segment.Padding)
node.Lines().Append(seg)
return parser.Continue | parser.NoChildren
Expand Down
4 changes: 2 additions & 2 deletions modules/markup/markdown/math/block_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func (r *BlockRenderer) writeLines(w util.BufWriter, source []byte, n gast.Node)
func (r *BlockRenderer) renderBlock(w util.BufWriter, source []byte, node gast.Node, entering bool) (gast.WalkStatus, error) {
n := node.(*Block)
if entering {
code := giteaUtil.Iif(n.Inline, "", `<pre class="code-block is-loading">`) + `<code class="language-math display">`
code := giteaUtil.Ternary(n.Inline, "", `<pre class="code-block is-loading">`) + `<code class="language-math display">`
_ = r.renderInternal.FormatWithSafeAttrs(w, template.HTML(code))
r.writeLines(w, source, n)
} else {
_, _ = w.WriteString(`</code>` + giteaUtil.Iif(n.Inline, "", `</pre>`) + "\n")
_, _ = w.WriteString(`</code>` + giteaUtil.Ternary(n.Inline, "", `</pre>`) + "\n")
}
return gast.WalkContinue, nil
}
8 changes: 4 additions & 4 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewFuncMap() template.FuncMap {
// -----------------------------------------------------------------
// html/template related functions
"dict": dict, // it's lowercase because this name has been widely used. Our other functions should have uppercase names.
"Iif": iif,
"Ternary": ternary,
"Eval": evalTokens,
"SafeHTML": safeHTML,
"HTMLFormat": htmlFormat,
Expand Down Expand Up @@ -233,9 +233,9 @@ func dotEscape(raw string) string {
return strings.ReplaceAll(raw, ".", "\u200d.\u200d")
}

// iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
// and it could be simply used as "{{iif expr trueVal}}" (omit the falseVal).
func iif(condition any, vals ...any) any {
// ternary is an "inline-if", similar util.Ternary[T] but templates need the non-generic version,
// and it can be simply used as "{{ternary expr trueVal}}" (omit the falseVal).
func ternary(condition any, vals ...any) any {
if isTemplateTruthy(condition) {
return vals[0]
} else if len(vals) > 1 {
Expand Down
4 changes: 2 additions & 2 deletions modules/templates/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestSanitizeHTML(t *testing.T) {

func TestTemplateIif(t *testing.T) {
tmpl := template.New("test")
tmpl.Funcs(template.FuncMap{"Iif": iif})
tmpl.Funcs(template.FuncMap{"Iif": ternary})
template.Must(tmpl.Parse(`{{if .Value}}true{{else}}false{{end}}:{{Iif .Value "true" "false"}}`))

cases := []any{nil, false, true, "", "string", 0, 1}
Expand All @@ -77,7 +77,7 @@ func TestTemplateIif(t *testing.T) {
w.Reset()
assert.NoError(t, tmpl.Execute(w, struct{ Value any }{v}), "case %d (%T) %#v fails", i, v, v)
out := w.String()
truthyCount += util.Iif(out == "true:true", 1, 0)
truthyCount += util.Ternary(out == "true:true", 1, 0)
truthyMatches := out == "true:true" || out == "false:false"
assert.True(t, truthyMatches, "case %d (%T) %#v fail: %s", i, v, v, out)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/templates/util_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML { //nolint:rev

func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink string, issue *issues_model.Issue) template.HTML {
isPullRequest := issue != nil && issue.IsPull
baseLink := fmt.Sprintf("%s/%s", repoLink, util.Iif(isPullRequest, "pulls", "issues"))
baseLink := fmt.Sprintf("%s/%s", repoLink, util.Ternary(isPullRequest, "pulls", "issues"))
htmlCode := `<span class="labels-list">`
for _, label := range labels {
// Protect against nil value in labels - shouldn't happen but would cause a panic if so
Expand Down
4 changes: 2 additions & 2 deletions modules/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func ToPointer[T any](val T) *T {
return &val
}

// Iif is an "inline-if", it returns "trueVal" if "condition" is true, otherwise "falseVal"
func Iif[T any](condition bool, trueVal, falseVal T) T {
// Ternary is an "inline-if", it returns "trueVal" if "condition" is true, otherwise "falseVal"
func Ternary[T any](condition bool, trueVal, falseVal T) T {
if condition {
return trueVal
}
Expand Down
2 changes: 1 addition & 1 deletion modules/web/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func chiURLParamsToMap(chiCtx *chi.Context) map[string]string {
}
m[key] = pathParams.Values[i]
}
return util.Iif(len(m) == 0, nil, m)
return util.Ternary(len(m) == 0, nil, m)
}

func TestPathProcessor(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions routers/api/packages/rubygems/rubygems.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func GetAllPackagesVersions(ctx *context.Context) {
// format: RUBYGEM [-]VERSION_PLATFORM[,VERSION_PLATFORM],...] MD5
_, _ = fmt.Fprintf(out, "%s ", pkg.Name)
for i, v := range versions {
sep := util.Iif(i == len(versions)-1, "", ",")
sep := util.Ternary(i == len(versions)-1, "", ",")
_, _ = fmt.Fprintf(out, "%s%s", v.Version, sep)
}
_, _ = fmt.Fprintf(out, " %x\n", md5.Sum([]byte(info)))
Expand All @@ -362,7 +362,7 @@ func writePackageVersionRequirements(prefix string, reqs []rubygems_module.Versi
reqs = []rubygems_module.VersionRequirement{{Restriction: ">=", Version: "0"}}
}
for i, req := range reqs {
sep := util.Iif(i == 0, "", "&")
sep := util.Ternary(i == 0, "", "&")
_, _ = fmt.Fprintf(out, "%s%s %s", sep, req.Restriction, req.Version)
}
}
Expand Down Expand Up @@ -391,7 +391,7 @@ func makePackageVersionDependency(ctx *context.Context, version *packages_model.
buf.WriteString(version.Version)
buf.WriteByte(' ')
for i, dep := range metadata.RuntimeDependencies {
sep := util.Iif(i == 0, "", ",")
sep := util.Ternary(i == 0, "", ",")
writePackageVersionRequirements(fmt.Sprintf("%s%s:", sep, dep.Name), dep.Version, buf)
}
_, _ = fmt.Fprintf(buf, "|checksum:%s", blob.HashSHA256)
Expand Down
4 changes: 2 additions & 2 deletions routers/api/v1/misc/markup.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Markup(ctx *context.APIContext) {
return
}

mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck
mode := util.Ternary(form.Wiki, "wiki", form.Mode) //nolint:staticcheck
common.RenderMarkup(ctx.Base, ctx.Repo, mode, form.Text, form.Context, form.FilePath)
}

Expand Down Expand Up @@ -73,7 +73,7 @@ func Markdown(ctx *context.APIContext) {
return
}

mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck
mode := util.Ternary(form.Wiki, "wiki", form.Mode) //nolint:staticcheck
common.RenderMarkup(ctx.Base, ctx.Repo, mode, form.Text, form.Context, "")
}

Expand Down
2 changes: 1 addition & 1 deletion routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func InitWebInstalled(ctx context.Context) {
mustInitCtx(ctx, git.InitFull)
log.Info("Git version: %s (home: %s)", git.DefaultFeatures().VersionInfo(), git.HomeDir())
if !git.DefaultFeatures().SupportHashSha256 {
log.Warn("sha256 hash support is disabled - requires Git >= 2.42." + util.Iif(git.DefaultFeatures().UsingGogit, " Gogit is currently unsupported.", ""))
log.Warn("sha256 hash support is disabled - requires Git >= 2.42." + util.Ternary(git.DefaultFeatures().UsingGogit, " Gogit is currently unsupported.", ""))
}

// Setup i18n
Expand Down
2 changes: 1 addition & 1 deletion routers/web/devtest/mock_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func generateMockStepsLog(logCur actions.LogCursor) (stepsLog []*actions.ViewSte
"##[endgroup]",
}
cur := logCur.Cursor // usually the cursor is the "file offset", but here we abuse it as "line number" to make the mock easier, intentionally
mockCount := util.Iif(logCur.Step == 0, 3, 1)
mockCount := util.Ternary(logCur.Step == 0, 3, 1)
if logCur.Step == 1 && logCur.Cursor == 0 {
mockCount = 30 // for the first batch, return as many as possible to test the auto-expand and auto-scroll
}
Expand Down
2 changes: 1 addition & 1 deletion routers/web/explore/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Organizations(ctx *context.Context) {
)
sortOrder := ctx.FormString("sort")
if sortOrder == "" {
sortOrder = util.Iif(supportedSortOrders.Contains(setting.UI.ExploreDefaultSort), setting.UI.ExploreDefaultSort, "newest")
sortOrder = util.Ternary(supportedSortOrders.Contains(setting.UI.ExploreDefaultSort), setting.UI.ExploreDefaultSort, "newest")
ctx.SetFormString("sort", sortOrder)
}

Expand Down
2 changes: 1 addition & 1 deletion routers/web/explore/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func Users(ctx *context.Context) {
)
sortOrder := ctx.FormString("sort")
if sortOrder == "" {
sortOrder = util.Iif(supportedSortOrders.Contains(setting.UI.ExploreDefaultSort), setting.UI.ExploreDefaultSort, "newest")
sortOrder = util.Ternary(supportedSortOrders.Contains(setting.UI.ExploreDefaultSort), setting.UI.ExploreDefaultSort, "newest")
ctx.SetFormString("sort", sortOrder)
}

Expand Down
2 changes: 1 addition & 1 deletion routers/web/misc/markup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ import (
// Markup render markup document to HTML
func Markup(ctx *context.Context) {
form := web.GetForm(ctx).(*api.MarkupOption)
mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck
mode := util.Ternary(form.Wiki, "wiki", form.Mode) //nolint:staticcheck
common.RenderMarkup(ctx.Base, ctx.Repo, mode, form.Text, form.Context, form.FilePath)
}
2 changes: 1 addition & 1 deletion routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func home(ctx *context.Context, viewRepositories bool) {
}

func prepareOrgProfileReadme(ctx *context.Context, prepareResult *shared_user.PrepareOrgHeaderResult) bool {
viewAs := ctx.FormString("view_as", util.Iif(ctx.Org.IsMember, "member", "public"))
viewAs := ctx.FormString("view_as", util.Ternary(ctx.Org.IsMember, "member", "public"))
viewAsMember := viewAs == "member"

var profileRepo *repo_model.Repository
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/actions/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func getActionsViewArtifacts(ctx context.Context, repoID, runIndex int64) (artif
artifactsViewItems = append(artifactsViewItems, &ArtifactsViewItem{
Name: art.ArtifactName,
Size: art.FileSize,
Status: util.Iif(art.Status == actions_model.ArtifactStatusExpired, "expired", "completed"),
Status: util.Ternary(art.Status == actions_model.ArtifactStatusExpired, "expired", "completed"),
})
}
return artifactsViewItems, nil
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
ctx.Data["TreePaths"] = treePaths
ctx.Data["commit_summary"] = ""
ctx.Data["commit_message"] = ""
ctx.Data["commit_choice"] = util.Iif(canCommit, frmCommitChoiceDirect, frmCommitChoiceNewBranch)
ctx.Data["commit_choice"] = util.Ternary(canCommit, frmCommitChoiceDirect, frmCommitChoiceNewBranch)
ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx)
ctx.Data["last_commit"] = ctx.Repo.CommitID

Expand Down
Loading