reworking database, init and add commands

This commit is contained in:
2020-07-02 15:00:30 -04:00
parent 6379c73e38
commit 5af55ed62e
15 changed files with 220 additions and 295 deletions

View File

@@ -1,52 +1,12 @@
version = "0.1.5"
loglevel = 2
loglevel = 0
rootpath = ""
reponame = "gvc"
currentbranch = "master"
localbranches = ["master", "localbranch1", "localbranch2"]
remotebranches = ["master", "serveronlybranch", "anotherserverbranch"]
[[remote]]
name = "test2"
host = "localhost"
port = 80
default = true
[[remote]]
name = "test4"
host = "localhost"
port = 9998
default = false
[[remote]]
name = "test3"
host = "localhost"
port = 9997
default = false
[[remote]]
name = "test5"
host = "localhost1"
port = 9997
default = false
[[remote]]
name = "test6"
host = "localhost1"
port = 9995
default = false
reponame = ""
currentbranch = ""
[locked]
files = ["client1.exe", "client2.exe", "client.go", "serverLocked.go"]
exts = [".exeServer", "serverCOMP2EXT"]
[ignore]
files = ["client1.exe", "client2.exe", "client3.exe", "client4.exe", "client5.exe", "client6.exe", "client7.exe", "test1\\client8.exe", "clientcmd\\init.go", "localignoreonly.go"]
exts = [".exe", ".tl"]
folders = ["serverFolderIgnore", "serverFolderignore2"]
[nocompress]
files = ["localnocompress.go"]
exts = ["serverNoCompressEXT", "serverCOMP2EXT"]
folders = []

Binary file not shown.

View File

@@ -1,173 +1,15 @@
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"added file: client.go at path: client.go with hash: \ufffd\ufffd\u0001{\ufffd[Ȼ[8\ufffdR!\ufffd\ufffdB at time: %!s(func() string=0x68c530)"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"added file: client.go at path: client.go with hash: \ufffd\ufffd\u0001{\ufffd[Ȼ[8\ufffdR!\ufffd\ufffdB at time: %!s(func() string=0x68c6a0)"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"added file: client.go at path: client.go with hash: \ufffd\ufffd\u0001{\ufffd[Ȼ[8\ufffdR!\ufffd\ufffdB at time: %!s(func() string=0x68c6a0)"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: test.go at path: test.go with hash: \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000 at time: %!s(func() string=0x68c480)"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"unable to add file to repo: file already found in tracked files, not adding: client.go\n"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"unable to add file to repo: file already found in tracked files, not adding: client.go\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: add.go at path: clientcmd\\add.go with hash: \ufffd4\ufffd\ufffdb&\ufffd\ufffd\ufffdNR\ufffd\ufffdV\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: branch.go at path: clientcmd\\branch.go with hash: \ufffd\u0006\ufffd\ufffd\ufffd\ufffd[^\u0015M\ufffd\ufffd(Z\ufffdc at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: commonlib.go at path: clientcmd\\commonlib.go with hash: \ufffd\u000fMQ<\ufffd\ufffd\u0016\ufffdM&z\u0010\ufffdw\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: ignore.go at path: clientcmd\\ignore.go with hash: \ufffd!\u0007\ufffd35z\n\ufffdG\b1R\ufffd\ufffdC at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: info.go at path: clientcmd\\info.go with hash: \ufffd\u0007\ufffd3*\ufffd\ufffdD:zX\ufffdѳ\ufffd\u000b at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: init.go at path: clientcmd\\init.go with hash: \ufffd\u0004\ufffd\ufffd6!\ufffd\u0017\ufffd{\ufffdfHH\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: lock.go at path: clientcmd\\lock.go with hash: \ufffd,1\ufffd\ufffd\ufffd\ufffdn\ufffd1\ufffdK+\u0003\ufffd? at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: refresh.go at path: clientcmd\\refresh.go with hash: \ufffd\u0019\ufffd\ufffd\ufffd\ufffdh\ufffd\ufffdzx,\ufffd\ufffd\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: remote.go at path: clientcmd\\remote.go with hash: \ufffd\fh۫\ufffd)D\ufffd\ufffd\ufffdFg\ufffd\ufffd\u0012 at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: switch.go at path: clientcmd\\switch.go with hash: \ufffd\u0004J\u000b\ufffd\ufffd\ufffd?\ufffd\ufffd\ufffdEw\ufffd^Q at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: config.go at path: clientconfig\\config.go with hash: \ufffd\u001bf\ufffdE_\u0017-\ufffd\ufffd\ufffd1\ufffd'<\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: structures.go at path: clientconfig\\structures.go with hash: \ufffd\fc\ufffd\u0000\ufffd\ufffdbs\ufffd\ufffd\ufffdc\r\ufffd\b at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: test.go at path: test\\test.go with hash: \ufffd\u0002\ufffd|\ufffd`\ufffd\ufffd\u0002W\ufffdE\u007fd\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"info","message":"unable to add file to repo: file already found in tracked files, not adding: test.go\n"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"skipping .gvc directory: %!s(<nil>)\n"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Adding all files..."}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"skipping .gvc directory"}
{"level":"error","module":"database","error":"database not open","message":"Error finding file by path"}
{"level":"error","module":"database","error":"database not open","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [.gvcignore.toml] is monitored. Error database not open"}
{"level":"info","message":"No files found that could be added to tracked"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"Adding all files..."}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"unable to add file to repo: file already found in tracked files, not adding: client.go\n"}
{"level":"info","message":"unable to add file to repo: file already found in tracked files, not adding: clientcmd\\add.go\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\branch.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\commonlib.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\ignore.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\info.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\init.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\lock.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\refresh.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\remote.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientcmd\\switch.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientconfig\\config.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [clientconfig\\structures.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [test\\test.go] is monitored. Error already exists"}
{"level":"info","message":"unable to add file to repo: already exists\n"}
{"level":"info","message":"unable to add file to repo: file already found in tracked files, not adding: test.go\n"}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"Creating new Manager..."}
{"level":"warn","module":"database","message":"No existing databse found. initialising new database"}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"skipping .gvc directory"}
{"level":"info","message":"Creating new Manager..."}
{"level":"info","message":"skipping .gvc directory"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: client.go at path: client.go with hash: \ufffd\ufffd\u00013\ufffdw\ufffd*\ufffd\ufffd\ufffdb?x\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: add.go at path: clientcmd\\add.go with hash: \ufffd8\u0001\\\u001e+\ufffdx}ҟL\ufffd<\ufffdM at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: branch.go at path: clientcmd\\branch.go with hash: \ufffd\u0006\ufffd\ufffd\ufffd\ufffd[^\u0015M\ufffd\ufffd(Z\ufffdc at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: commonlib.go at path: clientcmd\\commonlib.go with hash: \ufffd\u000fMQ<\ufffd\ufffd\u0016\ufffdM&z\u0010\ufffdw\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: ignore.go at path: clientcmd\\ignore.go with hash: \ufffd!\u0007\ufffd35z\n\ufffdG\b1R\ufffd\ufffdC at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: info.go at path: clientcmd\\info.go with hash: \ufffd\u0007\ufffd3*\ufffd\ufffdD:zX\ufffdѳ\ufffd\u000b at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: init.go at path: clientcmd\\init.go with hash: \ufffd\u0004\ufffd\ufffd6!\ufffd\u0017\ufffd{\ufffdfHH\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: lock.go at path: clientcmd\\lock.go with hash: \ufffd,1\ufffd\ufffd\ufffd\ufffdn\ufffd1\ufffdK+\u0003\ufffd? at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: refresh.go at path: clientcmd\\refresh.go with hash: \ufffd\u0019\ufffd\ufffd\ufffd\ufffdh\ufffd\ufffdzx,\ufffd\ufffd\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: remote.go at path: clientcmd\\remote.go with hash: \ufffd\fh۫\ufffd)D\ufffd\ufffd\ufffdFg\ufffd\ufffd\u0012 at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: switch.go at path: clientcmd\\switch.go with hash: \ufffd\u0004J\u000b\ufffd\ufffd\ufffd?\ufffd\ufffd\ufffdEw\ufffd^Q at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: config.go at path: clientconfig\\config.go with hash: \ufffd\u001bf\ufffdE_\u0017-\ufffd\ufffd\ufffd1\ufffd'<\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: structures.go at path: clientconfig\\structures.go with hash: \ufffd\fc\ufffd\u0000\ufffd\ufffdbs\ufffd\ufffd\ufffdc\r\ufffd\b at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: test.go at path: test\\test.go with hash: \ufffd\u0002\ufffd|\ufffd`\ufffd\ufffd\u0002W\ufffdE\u007fd\ufffd\ufffd at time: %!s(func() string=0x68c7c0)"}
{"level":"warn","module":"database","message":"no file found"}
{"level":"info","message":"added file: test.go at path: test.go with hash: \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000 at time: %!s(func() string=0x68c7c0)"}
{"level":"info","message":"Adding the following files to tracked: [client.go clientcmd\\add.go clientcmd\\branch.go clientcmd\\commonlib.go clientcmd\\ignore.go clientcmd\\info.go clientcmd\\init.go clientcmd\\lock.go clientcmd\\refresh.go clientcmd\\remote.go clientcmd\\switch.go clientconfig\\config.go clientconfig\\structures.go test\\test.go test.go]"}
{"level":"error","module":"database","error":"database not open","message":"Error finding file by path"}
{"level":"error","module":"database","error":"database not open","message":"Error initialising file in database"}
{"level":"error","message":"Error checking if file [.gvcignore.toml] is monitored. Error database not open"}
{"level":"info","message":"No files found that could be added to tracked"}

View File

@@ -11,6 +11,7 @@ import (
clientconfig "github.com/deranjer/gvc/client/clientconfig"
config "github.com/deranjer/gvc/client/clientconfig"
"github.com/deranjer/gvc/common"
"github.com/deranjer/gvc/common/database"
"github.com/deranjer/gvc/common/engine"
"github.com/deranjer/store"
"github.com/rs/zerolog"
@@ -18,6 +19,7 @@ import (
var version = "0.1.5"
var configPath = ".gvc" + string(filepath.Separator) + ".gvcconfig.toml"
var dbPath = ".gvc/gvc.db"
var rootPath string
func main() {
@@ -45,12 +47,6 @@ func main() {
fmt.Println("Error validating config, your config file is corrupt! ", err)
os.Exit(0)
}
fmt.Println("Attempting to start logger...")
// Checking the .gvc structure
dirPaths, err := engine.CheckPaths(rootPath)
if err != nil {
log.Fatalf("unable to create/verify .gvc folder structure: %s", err)
}
// Setting up the logger to file output
logFile, err := os.OpenFile(".gvc/logs/gvclog.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
@@ -62,15 +58,17 @@ func main() {
if err != nil {
fmt.Println("invalid log level set in config, setting to info")
}
fmt.Println("Attempting to start logger...")
clientlog := zerolog.New(logFile)
clientlog.WithLevel(logLevel)
// Check/Setup the database with logging
//db, err := database.OpenOrCreateDB(".gvc/gvc.db", &clientlog)
//if err != nil {
// clientlog.Fatal().Msgf("Unable to open or create a database in the .gvc folder, fatal")
//}
// now checking the .gvc structure, currently will just create if they don't exist
dirPaths, err := engine.CheckPaths(rootPath)
if err != nil {
clientlog.Err(err).Msgf("unable to verify .gvc folder structure, attempting to create missing structure: %s", err)
}
engine.CreatePaths(rootPath) //currently will fatal fail if can't create paths
informer := make(chan engine.OperatingMessage)
m, err = engine.NewManager(rootPath, version, ".gvc/gvc.db", informer, dirPaths, &clientlog)
m, err = engine.NewManager(rootPath, version, dbPath, informer, dirPaths, &clientlog)
if err != nil {
clientlog.Fatal().Msgf("unable to create new manager object... %s", err)
}
@@ -80,7 +78,7 @@ func main() {
cli := clir.NewCli("gvcc", "Version control client for GVC", version)
// Adding the init command
initCommand(cli, &conf)
initCommand(cli, &conf, dbPath)
// Adding all the "add" commands
addCommands(cli, &conf, m)
@@ -133,6 +131,11 @@ func validateRepo() bool {
if _, err := os.Stat(configPath); os.IsNotExist(err) {
return false
}
// See if database exits, if not, not a valid repo
err := database.CheckDB(".gvc/gvc.db")
if err != nil {
return false
}
return true
}
@@ -154,20 +157,23 @@ func refreshCommand(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
})
}
func initCommand(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
func initCommand(cli *clir.Cli, conf *clientconfig.Gvcconfig, dbPath string) {
//The init subcommand
initCmd := cli.NewSubCommand("init", "initializes a new gvc repo")
initCmd.LongDescription("This will create the .gvcconfig.toml (with defaults) file in this directory. You can edit this file directly (unsafe) or with the client(safe)")
initCmd.Action(func() error {
isRepo := validateRepo()
if !isRepo {
repoName := clientcmd.InitializeRepo() // creates and checks the paths
repoName, err := clientcmd.InitializeRepo(dbPath, version, rootPath) // creates and checks the paths
if err != nil {
log.Fatalf("unable to create new repo: %s", err)
}
newConf := clientconfig.Gvcconfig{
RepoName: repoName,
Version: version,
CurrentBranch: "master",
}
err := store.Save(configPath, &newConf)
err = store.Save(configPath, &newConf)
if err != nil {
log.Fatalf("unable to create new config in .gvc %s", err)
}

View File

@@ -97,6 +97,7 @@ func AddFiles(input string, inputType string, ignore common.FileTypes, m *engine
} else {
wildcard = input
}
m.Info().Msgf("Adding all files with wildcard: %s", wildcard)
err := common.CheckFileTypes(wildcard, "wildcard", ignore)
if err != nil {
return err
@@ -146,6 +147,7 @@ func AddFiles(input string, inputType string, ignore common.FileTypes, m *engine
return nil
})
case "all":
m.Info().Msg("Adding all files...")
filepath.Walk(workingDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("failure accessing path %s", err)

View File

@@ -1,13 +1,18 @@
package clientcmd
import (
"fmt"
clientconfig "github.com/deranjer/gvc/client/clientconfig"
"github.com/deranjer/gvc/common/engine"
)
// Commit commits the tracked files and changes to the repo
func Commit(conf *clientconfig.Gvcconfig, commitMessage string, m *engine.Manager) error {
m.BeginCommit(conf.CurrentBranch, commitMessage)
err := m.BeginCommit(conf.CurrentBranch, commitMessage)
if err != nil {
return fmt.Errorf("begin commit failed with message: %s", err)
}
return nil
}

View File

@@ -25,7 +25,7 @@ func validateFileType(path string, inputType string) error {
return fmt.Errorf("unable to read file, corrupted? %s", err)
}
if fileInfo.IsDir() {
if inputType == "folder" {
if inputType == "folder" || inputType == "all" {
return nil
} else {
return fmt.Errorf("folder flag was used, but input is not a folder, will not continue")

View File

@@ -2,23 +2,41 @@ package clientcmd
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/deranjer/gvc/common/database"
"github.com/deranjer/gvc/common/engine"
)
// InitializeRepo creates the repo directory and a new config file
func InitializeRepo() string {
func InitializeRepo(dbPath string, version string, rootPath string) (string, error) {
cwd, err := os.Getwd()
if err != nil {
log.Fatal("unable to get current working directory.. permissions issue?")
fmt.Printf("unable to get current working directory.. permissions issue? %s\n", err)
return "", err
}
repoName := filepath.Base(cwd)
fmt.Println("Initializing repo in dir: ", cwd)
err = os.Mkdir(".gvc", 0644)
if err != nil {
fmt.Println(".gvc directory already exists, but no config file... continuing")
fmt.Printf(".gvc directory already exists, but no config file... continuing")
}
err = engine.CreatePaths(rootPath)
if err != nil {
fmt.Printf("unable to create root dir paths.. permissions issue? %s\n", err)
return "", err
}
fmt.Println("Creating DB...")
err = database.CreateDB(dbPath, version, repoName)
if err != nil {
fmt.Printf("unable to create db: %s\n", err)
err := os.Remove(dbPath)
if err != nil {
fmt.Printf("unable to roll back database, cannot delete db: %s err: %s", dbPath, err)
}
return "", err
}
repoName := filepath.Base(cwd)
fmt.Println("Adding new repo with name: ", repoName)
return repoName
return repoName, nil
}