moving a function and struct over to a common library, starting on lockfile for server
This commit is contained in:
		@@ -4,18 +4,19 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	clientconfig "github.com/deranjer/gvc/client/clientconfig"
 | 
			
		||||
	"github.com/deranjer/gvc/common"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
//IgnoreFiles ignores file(s)/folder based on name/wildcard, etc
 | 
			
		||||
func IgnoreFiles(input string, inputType string, conf *clientconfig.Gvcconfig) error {
 | 
			
		||||
	err := validateFileType(input, inputType) // Making sure that if the file flag was used a folder was not supplied and vice versa
 | 
			
		||||
	err := validateFileType(input, inputType) // Making sure that if the file flag was used a folder was not supplied and vice versa //TODO: Not needed I don't think we need user to be able to add ignores before files are there
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	ignore := conf.Ignores
 | 
			
		||||
	switch inputType { // TODO: add default case for generic error handling
 | 
			
		||||
	case "file":
 | 
			
		||||
		err := checkFileTypes(input, "file", ignore)
 | 
			
		||||
		err := common.CheckFileTypes(input, "file", ignore)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("%s already ignored: %s", input, err)
 | 
			
		||||
		}
 | 
			
		||||
@@ -23,7 +24,7 @@ func IgnoreFiles(input string, inputType string, conf *clientconfig.Gvcconfig) e
 | 
			
		||||
		conf.Ignores.Files = append(conf.Ignores.Files, input)
 | 
			
		||||
		return nil
 | 
			
		||||
	case "folder":
 | 
			
		||||
		err := checkFileTypes(input, "folder", ignore)
 | 
			
		||||
		err := common.CheckFileTypes(input, "folder", ignore)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("%s is already ignored: %s", input, err)
 | 
			
		||||
		}
 | 
			
		||||
@@ -37,7 +38,7 @@ func IgnoreFiles(input string, inputType string, conf *clientconfig.Gvcconfig) e
 | 
			
		||||
		} else {
 | 
			
		||||
			wildcard = input
 | 
			
		||||
		}
 | 
			
		||||
		err := checkFileTypes(wildcard, "wildcard", ignore)
 | 
			
		||||
		err := common.CheckFileTypes(wildcard, "wildcard", ignore)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("%s is already ignored: %s", input, err)
 | 
			
		||||
		}
 | 
			
		||||
@@ -50,14 +51,14 @@ func IgnoreFiles(input string, inputType string, conf *clientconfig.Gvcconfig) e
 | 
			
		||||
 | 
			
		||||
// RemoveIgnoreFiles removes files/folders/wildcards from the ignore list
 | 
			
		||||
func RemoveIgnoreFiles(input string, inputType string, conf *clientconfig.Gvcconfig) error {
 | 
			
		||||
	err := validateFileType(input, inputType) // Making sure that if the file flag was used a folder was not supplied and vice versa
 | 
			
		||||
	err := validateFileType(input, inputType) // Making sure that if the file flag was used a folder was not supplied and vice versa //TODO: Not needed I don't think we need user to be able to add ignores before files are there
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	ignore := conf.Ignores
 | 
			
		||||
	switch inputType { // TODO: add default case for generic error handling
 | 
			
		||||
	case "file":
 | 
			
		||||
		err := checkFileTypes(input, "file", ignore)
 | 
			
		||||
		err := common.CheckFileTypes(input, "file", ignore)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Println("Removing file from ignores: ", input)
 | 
			
		||||
			for i, fileIgnore := range ignore.Files {
 | 
			
		||||
@@ -72,7 +73,7 @@ func RemoveIgnoreFiles(input string, inputType string, conf *clientconfig.Gvccon
 | 
			
		||||
		fmt.Println("File not found in ingores, unable to remove: ", input)
 | 
			
		||||
		return nil
 | 
			
		||||
	case "folder":
 | 
			
		||||
		err := checkFileTypes(input, "folder", ignore)
 | 
			
		||||
		err := common.CheckFileTypes(input, "folder", ignore)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			for i, folderIgnore := range ignore.Folders {
 | 
			
		||||
				if input == folderIgnore {
 | 
			
		||||
@@ -92,7 +93,7 @@ func RemoveIgnoreFiles(input string, inputType string, conf *clientconfig.Gvccon
 | 
			
		||||
		} else {
 | 
			
		||||
			wildcard = input
 | 
			
		||||
		}
 | 
			
		||||
		err := checkFileTypes(wildcard, "wildcard", ignore)
 | 
			
		||||
		err := common.CheckFileTypes(wildcard, "wildcard", ignore)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			for i, wildcardIgnore := range ignore.Exts {
 | 
			
		||||
				if input == wildcardIgnore {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user