package command import ( "fmt" "github.com/isacikgoz/gitbatch/internal/git" ) // ConfigOptions defines the rules for commit operation type ConfigOptions struct { // Section Section string // Option Option string // Site should be Global or Local Site ConfigSite // Mode is the command mode CommandMode Mode } // ConfigSite defines a string type for the site. type ConfigSite string const ( // ConfigSiteLocal defines a local config. ConfigSiteLocal ConfigSite = "local" // ConfigSiteGlobal defines a global config. ConfigSiteGlobal ConfigSite = "global" ) // Config adds or reads config of a repository func Config(r *git.Repository, o *ConfigOptions) (value string, err error) { // here we configure config operation switch o.CommandMode { case ModeLegacy: return configWithGit(r, o) case ModeNative: return configWithGoGit(r, o) } return value, fmt.Errorf("unhandled config operation") } // configWithGit is simply a bare git config --site