Some checks failed
Build and Release / Create Release (push) Successful in 0s
Trigger Vault Plugin Rebuild / Trigger Vault Rebuild (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Lint (push) Failing after 5m2s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux, linux-latest) (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 5m37s
Go's semantic import versioning requires v2+ modules to include the major version in the module path. This enables using proper version tags (v3.x.x) instead of pseudo-versions. Updated module path: code.gitcaddy.com/server/v3
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package private
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"code.gitcaddy.com/server/v3/modules/optional"
|
|
)
|
|
|
|
// GitPushOptions is a wrapper around a map[string]string
|
|
type GitPushOptions map[string]string
|
|
|
|
// GitPushOptions keys
|
|
const (
|
|
GitPushOptionRepoPrivate = "repo.private"
|
|
GitPushOptionRepoTemplate = "repo.template"
|
|
GitPushOptionForcePush = "force-push"
|
|
)
|
|
|
|
// Bool checks for a key in the map and parses as a boolean
|
|
// An option without value is considered true, eg: "-o force-push" or "-o repo.private"
|
|
func (g GitPushOptions) Bool(key string) optional.Option[bool] {
|
|
if val, ok := g[key]; ok {
|
|
if val == "" {
|
|
return optional.Some(true)
|
|
}
|
|
if b, err := strconv.ParseBool(val); err == nil {
|
|
return optional.Some(b)
|
|
}
|
|
}
|
|
return optional.None[bool]()
|
|
}
|
|
|
|
// AddFromKeyValue adds a key value pair to the map by "key=value" format or "key" for empty value
|
|
func (g GitPushOptions) AddFromKeyValue(line string) {
|
|
kv := strings.SplitN(line, "=", 2)
|
|
if len(kv) == 2 {
|
|
g[kv[0]] = kv[1]
|
|
} else {
|
|
g[kv[0]] = ""
|
|
}
|
|
}
|