Browse Source

Move ~/.config/yay_vcs.json to ~/.cache/vcs.json

And refactor the file paths to constants in config.go
morganamilo 7 năm trước cách đây
mục cha
commit
1d3a87bd70
3 tập tin đã thay đổi với 13 bổ sung4 xóa
  1. 3 3
      cmd.go
  2. 9 0
      config.go
  3. 1 1
      vcs.go

+ 3 - 3
cmd.go

@@ -90,9 +90,9 @@ func initYay() (err error) {
 		cacheHome = os.Getenv("HOME") + "/.cache/yay"
 	}
 
-	configFile = configHome + "/config.json"
-	vcsFile = configHome + "/yay_vcs.json"
-	completionFile = cacheHome + "/aur_"
+	configFile = configHome + "/" + configFileName
+	vcsFile = cacheHome + "/" + vcsFileName
+	completionFile = cacheHome + "/" + completionFilePrefix
 
 	////////////////
 	// yay config //

+ 9 - 0
config.go

@@ -43,6 +43,15 @@ type Configuration struct {
 
 var version = "3.373"
 
+// configFileName holds the name of the config file.
+const configFileName string = "config.json"
+
+// vcsFileName holds the name of the vcs file.
+const vcsFileName string = "vcs.json"
+
+// completionFilePrefix holds the prefix used for storing shell completion files.
+const completionFilePrefix string = "aur_"
+
 // baseURL givers the AUR default address.
 const baseURL string = "https://aur.archlinux.org"
 

+ 1 - 1
vcs.go

@@ -33,7 +33,7 @@ func createDevelDB() error {
 	return err
 }
 
-// parseSource returns the git url and efault branch
+// parseSource returns the git url, default branch and protocols it supports
 func parseSource(source string) (url string, branch string, protocols []string) {
 	if !(strings.Contains(source, "git://") ||
 		strings.Contains(source, ".git") ||