working on adding files to repo

This commit is contained in:
2020-05-28 17:41:13 -04:00
parent 9b017f3128
commit 8c59c4b067
3 changed files with 171 additions and 6 deletions

View File

@@ -1,4 +1,41 @@
package clientcmd
import (
"fmt"
"path/filepath"
clientconfig "github.com/deranjer/gvc/client/clientconfig"
)
// ConfigPath is the global path to the config that is injected from the main client package.
var ConfigPath string
func checkIgnores(input string, inputType string, ignores clientconfig.Ignore) error {
switch inputType {
case "file":
fileExt := filepath.Ext(input) // TODO more sanity checking on ext
for _, ignoredExt := range ignores.Exts {
if fileExt == ignoredExt {
return fmt.Errorf("file ext is on ignored list, cannot add file with file ext %s", fileExt)
}
}
for _, ignoredFile := range ignores.Files {
if input == ignoredFile {
return fmt.Errorf("file name is on ignored list, cannot add file with name %s", input)
}
}
case "folder":
for _, ignoredFolder := range ignores.Folders {
if input == ignoredFolder {
return fmt.Errorf("folder name is on the ignored list, cannot add folder with name %s", input)
}
}
case "wildcard":
for _, ignoredExt := range ignores.Exts {
if input == ignoredExt {
return fmt.Errorf("cannot add wildcard, since that ext is already added to the ignore config %s", input)
}
}
}
return nil
}