cleaning up manager, tying it to add files
This commit is contained in:
@@ -7,10 +7,11 @@ import (
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
"github.com/deranjer/gvc/common"
|
||||
"github.com/deranjer/gvc/common/manager"
|
||||
)
|
||||
|
||||
//AddFiles adds files to the repo, inputType specifies file, folder, wildcard or all
|
||||
func AddFiles(input string, inputType string, ignore common.FileTypes) error {
|
||||
func AddFiles(input string, inputType string, ignore common.FileTypes, m *manager.Manager) error {
|
||||
err := validateFileType(input, inputType) // Making sure that if the file flag was used a folder was not supplied and vice versa
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -30,9 +31,17 @@ func AddFiles(input string, inputType string, ignore common.FileTypes) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to add file as it (or ext) is on the ignores list %s", input)
|
||||
}
|
||||
relativePath, err := filepath.Rel(workingDir, input)
|
||||
// absolute := filepath.IsAbs(input)
|
||||
// if absolute {
|
||||
// relativePath, err := filepath.Rel(workingDir, input)
|
||||
// if err != nil {
|
||||
// return fmt.Errorf("unable to create relative path for file: %s", err)
|
||||
// }
|
||||
// }
|
||||
relativePath := input //TODO: Figure out if path is corrrect?
|
||||
err = m.AddFileToRepo(relativePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create relative path for file: %s", err)
|
||||
return fmt.Errorf("unable to add file to repo: %s", err)
|
||||
}
|
||||
trackedFiles = append(trackedFiles, relativePath)
|
||||
fmt.Println("adding file: ", relativePath)
|
||||
@@ -63,6 +72,10 @@ func AddFiles(input string, inputType string, ignore common.FileTypes) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create relative path for file: %s", err)
|
||||
}
|
||||
err = m.AddFileToRepo(relativePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to add file to repo: %s", err)
|
||||
}
|
||||
trackedFiles = append(trackedFiles, relativePath)
|
||||
return nil
|
||||
})
|
||||
@@ -98,6 +111,10 @@ func AddFiles(input string, inputType string, ignore common.FileTypes) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create relative path for file: %s", err)
|
||||
}
|
||||
err = m.AddFileToRepo(relativePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to add file to repo: %s", err)
|
||||
}
|
||||
trackedFiles = append(trackedFiles, relativePath)
|
||||
}
|
||||
return nil
|
||||
@@ -124,6 +141,10 @@ func AddFiles(input string, inputType string, ignore common.FileTypes) error {
|
||||
if relativePath == "." { //Ignoring current directory
|
||||
return nil
|
||||
}
|
||||
err = m.AddFileToRepo(relativePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to add file to repo: %s", err)
|
||||
}
|
||||
trackedFiles = append(trackedFiles, relativePath)
|
||||
return nil
|
||||
})
|
||||
|
Reference in New Issue
Block a user