From 7e6def5a5f25970fe7768859f854a9dd04f2be0a Mon Sep 17 00:00:00 2001 From: morganamilo Date: Wed, 7 Mar 2018 16:29:52 +0000 Subject: [PATCH] Add GitBin and tweak defaults Use cacheHome for builddir instead of hardcoding ~/.cache Use the command names in config.*Bin options. For example PacmanBin is changed to just "pacman" this means yay will call the pacman commit in PATH. If the user wants to use a different binary they can still specify a full path in the config. --- config.go | 10 ++++++---- vcs.go | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index 0d0b2373..cf3bca0a 100644 --- a/config.go +++ b/config.go @@ -32,6 +32,7 @@ type Configuration struct { PacmanConf string `json:"pacmanconf"` TarBin string `json:"tarbin"` ReDownload string `json:"redownload"` + GitBin string `json:"gitbin"` RequestSplitN int `json:"requestsplitn"` SearchMode int `json:"-"` SortMode int `json:"sortmode"` @@ -115,17 +116,18 @@ func (config *Configuration) saveConfig() error { } func defaultSettings(config *Configuration) { - config.BuildDir = fmt.Sprintf("%s/.cache/yay/", os.Getenv("HOME")) + config.BuildDir = cacheHome + "/" config.CleanAfter = false config.Editor = "" config.Devel = false - config.MakepkgBin = "/usr/bin/makepkg" + config.MakepkgBin = "makepkg" config.NoConfirm = false - config.PacmanBin = "/usr/bin/pacman" + config.PacmanBin = "pacman" config.PacmanConf = "/etc/pacman.conf" config.SortMode = BottomUp config.SudoLoop = false - config.TarBin = "/usr/bin/bsdtar" + config.TarBin = "bsdtar" + config.GitBin = "git" config.TimeUpdate = false config.RequestSplitN = 150 config.ReDownload = "no" diff --git a/vcs.go b/vcs.go index fd163a0d..b54963b2 100644 --- a/vcs.go +++ b/vcs.go @@ -103,7 +103,7 @@ func getCommit(url string, branch string, protocols []string) string { for _, protocol := range protocols { var outbuf bytes.Buffer - cmd := exec.Command("git", "ls-remote", protocol+"://"+url, branch) + cmd := exec.Command(config.GitBin, "ls-remote", protocol+"://"+url, branch) cmd.Stdout = &outbuf err := cmd.Start() @@ -144,7 +144,7 @@ func getCommit(url string, branch string, protocols []string) string { func (infos shaInfos) needsUpdate() bool { for url, info := range infos { hash := getCommit(url, info.Brach, info.Protocols) - if hash != info.SHA { + if hash != "" && hash != info.SHA { return true } }