6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-07 20:29:19 +00:00

Replace deprecated modules

Replace go-homedir with builtin os.UserHomeDir and pkg/errors with
builtin errors
This commit is contained in:
Grzegorz Dlugoszewski
2025-08-11 20:43:49 +02:00
parent 8cd27a8f62
commit 7ecef9c85d
7 changed files with 17 additions and 23 deletions

View File

@@ -5,10 +5,10 @@ package cfg
import (
"bytes"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
)
@@ -100,7 +100,11 @@ func readGitconfig(cfg Gitconfig) {
// Expand applies the variables expansion to a viper config of given key.
// If expansion fails or is not needed, the config is not modified.
func Expand(key string) {
if expanded, err := homedir.Expand(viper.GetString(key)); err == nil {
viper.Set(key, expanded)
path := viper.GetString(key)
if strings.HasPrefix(path, "~") {
if homeDir, err := os.UserHomeDir(); err == nil {
expanded := filepath.Join(homeDir, strings.TrimPrefix(path, "~"))
viper.Set(key, expanded)
}
}
}