mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
This commit adds yet another config handler for gopass. It is based on the format used by git itself. This has the potential to address a lot of long standing issues, but it also causes a lot of changes to how we handle configuration, so bugs are inevitable. Fixes #1567 Fixes #1764 Fixes #1819 Fixes #1878 Fixes #2387 Fixes #2418 RELEASE_NOTES=[BREAKING] New config format based on git config. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> address comments Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
36 lines
773 B
Go
36 lines
773 B
Go
package gitconfig
|
|
|
|
import "strings"
|
|
|
|
// splitKey splits a fully qualified gitconfig key into two or three parts.
|
|
// A valid key consists of either a section and a key separated by a dot
|
|
// or section, subsection and key, all separated by a dot. Note that
|
|
// the subsection might contain dots itself.
|
|
//
|
|
// Valid examples:
|
|
// - core.push
|
|
// - insteadof.git@github.com.push.
|
|
func splitKey(key string) (section, subsection, skey string) { //nolint:nonamedreturns
|
|
n := strings.Index(key, ".")
|
|
if n > 0 {
|
|
section = key[:n]
|
|
}
|
|
|
|
if m := strings.LastIndex(key, "."); n != m && m > 0 && len(key) > m+1 {
|
|
subsection = key[n+1 : m]
|
|
skey = key[m+1:]
|
|
|
|
return
|
|
}
|
|
|
|
skey = key[n+1:]
|
|
|
|
return
|
|
}
|
|
|
|
func trim(s []string) {
|
|
for i, e := range s {
|
|
s[i] = strings.TrimSpace(e)
|
|
}
|
|
}
|