Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
951cda3b25 | |||
cb24c6f2c8 | |||
ebd6e095f7 | |||
c07e09d155 | |||
5af55ed62e | |||
6379c73e38 | |||
07bbb442ef | |||
e4ac7f70e6 | |||
1ec7b436da | |||
47cc65a824 | |||
e75991da22 | |||
7610e3f168 | |||
8c01cdbcf4 | |||
55561d8667 | |||
88333417d4 | |||
d335549fd5 | |||
0ecb0b96ce | |||
2cbdf21a81 | |||
c4aa5a1c66 | |||
161843f4c8 | |||
441a9ed233 | |||
c2e74ce7f4 | |||
b2238657c8 | |||
6d738b138d | |||
dd3fd7c4ae | |||
23dd5090e3 | |||
4104193be3 | |||
b015680962 | |||
db2221c515 | |||
0276a1d776 | |||
33b1c78eb2 | |||
1a76a8f2aa | |||
4fee4cec7d | |||
0051b92c47 |
@@ -1,5 +1,10 @@
|
||||
version = "0.1.5"
|
||||
rootPath = ""
|
||||
loglevel = 0
|
||||
rootpath = ""
|
||||
reponame = "client"
|
||||
currentbranch = "master"
|
||||
|
||||
[locked]
|
||||
|
||||
[ignore]
|
||||
|
||||
|
@@ -1,25 +1,50 @@
|
||||
rootPath = "client"
|
||||
version = "0.1.5"
|
||||
rootpath = ""
|
||||
reponame = "gvc"
|
||||
currentbranch = "master"
|
||||
localbranches = ["master", "localbranch1", "localbranch2"]
|
||||
remotebranches = ["master"]
|
||||
|
||||
[[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
|
||||
|
||||
[locked]
|
||||
files = ["client1.exe", "client2.exe", "client.go", "locallocked.go"]
|
||||
|
||||
[ignore]
|
||||
files = [ "file1.txt", "file2.txt" ]
|
||||
exts = [ ".jpg", ".png" ]
|
||||
folders = []
|
||||
|
||||
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 = []
|
||||
|
||||
[nocompress]
|
||||
files = [ "fileA.log", "fileB.txt" ]
|
||||
exts = [ ".exe", ".jpg" ]
|
||||
folders = ["binaries"]
|
||||
|
||||
[[remote]]
|
||||
name = "origin"
|
||||
host = "testorigin.com"
|
||||
port = 8694
|
||||
|
||||
[[remote]]
|
||||
name = "secondOrigin"
|
||||
host = "170.5.95.195"
|
||||
port = 4253
|
||||
|
||||
files = ["localnocompress.go"]
|
||||
exts = []
|
||||
folders = []
|
||||
|
||||
|
@@ -5,11 +5,13 @@ rootPath = "client"
|
||||
name = "origin"
|
||||
host = "testorigin.com"
|
||||
port = 8694
|
||||
default = true
|
||||
|
||||
[[remote]]
|
||||
name = "secondOrigin"
|
||||
host = "170.5.95.195"
|
||||
port = 4253
|
||||
default = false
|
||||
|
||||
[ignore]
|
||||
files = ["file1.txt", "file2.txt"]
|
||||
|
BIN
client/.gvc/boltbrowser.exe
Normal file
BIN
client/.gvc/boltbrowser.exe
Normal file
Binary file not shown.
BIN
client/.gvc/gvc
Normal file
BIN
client/.gvc/gvc
Normal file
Binary file not shown.
BIN
client/.gvc/gvc.db
Normal file
BIN
client/.gvc/gvc.db
Normal file
Binary file not shown.
0
client/.gvc/gvc.db.lock
Normal file
0
client/.gvc/gvc.db.lock
Normal file
248
client/.gvc/logs/gvclog.log
Normal file
248
client/.gvc/logs/gvclog.log
Normal file
@@ -0,0 +1,248 @@
|
||||
{"level":"info","message":"Creating new Manager..."}
|
||||
{"level":"info","module":"database","message":"Fetching last commit on branch: master"}
|
||||
{"level":"info","module":"database","message":"Last commit was of number: 1 Last Commit Hash was: 45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b Last commit occurred on date: 2020-07-06 14:50:09.4015985 -0400 EDT m=+0.027025401"}
|
||||
{"level":"info","message":"Number of new Files: 240"}
|
||||
{"level":"info","message":"Starting commit number: 2 on branch: master"}
|
||||
{"level":"info","message":"Total number of files to commit: 16"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test2.go"}
|
||||
{"level":"info","message":"Converting changed file: client.go"}
|
||||
{"level":"info","message":"Converting changed file: add.go"}
|
||||
{"level":"info","message":"Converting changed file: branch.go"}
|
||||
{"level":"info","message":"Converting changed file: commit.go"}
|
||||
{"level":"info","message":"Converting changed file: commonlib.go"}
|
||||
{"level":"info","message":"Converting changed file: ignore.go"}
|
||||
{"level":"info","message":"Converting changed file: info.go"}
|
||||
{"level":"info","message":"Converting changed file: init.go"}
|
||||
{"level":"info","message":"Converting changed file: lock.go"}
|
||||
{"level":"info","message":"Converting changed file: refresh.go"}
|
||||
{"level":"info","message":"Converting changed file: remote.go"}
|
||||
{"level":"info","message":"Converting changed file: switch.go"}
|
||||
{"level":"info","message":"Converting changed file: config.go"}
|
||||
{"level":"info","message":"Converting changed file: structures.go"}
|
||||
{"level":"info","message":"Converting changed file: test.go.old"}
|
||||
{"level":"info","module":"database","message":"Writing new commit: %!s(int=2) on branch: master"}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
568
client/client.go
568
client/client.go
@@ -10,11 +10,16 @@ import (
|
||||
clientcmd "github.com/deranjer/gvc/client/clientcmd"
|
||||
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"
|
||||
)
|
||||
|
||||
var version = "0.1.5"
|
||||
var configPath = ".gvc" + string(filepath.Separator) + ".gvcconfig.toml"
|
||||
var dbPath = ".gvc/gvc.db"
|
||||
var rootPath string
|
||||
|
||||
func main() {
|
||||
@@ -25,39 +30,94 @@ func main() {
|
||||
var err error
|
||||
rootPath, err = os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalf("Can't get working dir, permissions issue %s", err)
|
||||
log.Fatalf("Can't get working dir, permissions issue? %s", err)
|
||||
}
|
||||
|
||||
// Setting up a blank config to read the .toml file in if one exists
|
||||
var conf clientconfig.Gvcconfig
|
||||
var m *engine.Manager
|
||||
isRepo := validateRepo()
|
||||
if isRepo {
|
||||
if isRepo { // If repo folder exists, treat it like a repo and setup logging and database. If not a repo will not need any of this
|
||||
err := store.Load(configPath, &conf)
|
||||
if err != nil {
|
||||
fmt.Println("Error loading config file into struct! ", err)
|
||||
fmt.Printf("Error loading config file into struct, please fix config, panic! \n%s", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
err = clientconfig.ValidateConfig(&conf, version)
|
||||
if err != nil {
|
||||
fmt.Println("Error validating config, your config file is corrupt! ", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
// 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 {
|
||||
log.Fatalf("unable to open log file at: %s, exiting with error: %s", ".gvc/logs/gvclog.log", err)
|
||||
}
|
||||
defer logFile.Close()
|
||||
// Setup non-http logging (using middleware for Echo http logging)
|
||||
logLevel, err := common.SetLogLevel(conf.LogLevel)
|
||||
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)
|
||||
// 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, dbPath, informer, dirPaths, &clientlog)
|
||||
if err != nil {
|
||||
clientlog.Fatal().Msgf("unable to create new manager object... %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize our new cli
|
||||
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)
|
||||
addCommands(cli, &conf, m)
|
||||
|
||||
// Adding the ignore commands
|
||||
ignoreCommands(cli, &conf)
|
||||
|
||||
// Adding the lock commands
|
||||
lockCommands(cli, &conf)
|
||||
|
||||
// Adding the test commands
|
||||
infoCommands(cli, &conf)
|
||||
|
||||
// Adding the refresh command
|
||||
refreshCommand(cli, &conf)
|
||||
|
||||
// Adding the "remote" commands
|
||||
remoteCommands(cli, &conf)
|
||||
|
||||
// Adding the "branch" command
|
||||
branchCommand(cli, &conf)
|
||||
|
||||
// Adding the "switch" command
|
||||
switchCommand(cli, &conf)
|
||||
|
||||
// Adding the "pull" command
|
||||
pullCommand(cli, &conf)
|
||||
|
||||
// Adding the "commit" command
|
||||
commitCommand(cli, &conf, m)
|
||||
|
||||
err = cli.Run()
|
||||
if err != nil {
|
||||
fmt.Printf("Error occurred: %v\n", err)
|
||||
}
|
||||
err = store.Save(configPath, conf)
|
||||
if err != nil {
|
||||
fmt.Println("Error saving config to file, changes were not writted! Check config file... ", err)
|
||||
}
|
||||
}
|
||||
|
||||
// injectVariables just injects the global variables into the packages
|
||||
@@ -71,21 +131,47 @@ 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
|
||||
}
|
||||
|
||||
func initCommand(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
// refreshCommand contacts the server and pulls down locked files/commits/etc to the client (like git fetch)
|
||||
func refreshCommand(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
refreshCmd := cli.NewSubCommand("refresh", "pulls down all locks/branches/commits unknown to client")
|
||||
refreshCmd.LongDescription("Works similar to git fetch where it shows the number of commits pushed to server/branches that the client doesn't know as well as file/folder locks")
|
||||
refreshCmd.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
err := clientcmd.RefreshContent(conf, conf.RepoName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to refresh content: %s", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
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 {
|
||||
clientcmd.InitializeRepo() // creates and checks the paths
|
||||
newConf := clientconfig.Gvcconfig{
|
||||
Version: version,
|
||||
repoName, err := clientcmd.InitializeRepo(dbPath, version, rootPath) // creates and checks the paths
|
||||
if err != nil {
|
||||
log.Fatalf("unable to create new repo: %s", err)
|
||||
}
|
||||
err := store.Save(configPath, &newConf)
|
||||
conf.RepoName = repoName
|
||||
conf.Version = version
|
||||
conf.CurrentBranch = "master"
|
||||
fmt.Println("Branch is now set to: ", conf.CurrentBranch)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to create new config in .gvc %s", err)
|
||||
}
|
||||
@@ -96,7 +182,7 @@ func initCommand(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
})
|
||||
}
|
||||
|
||||
func addCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
func addCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig, m *engine.Manager) {
|
||||
//All the add commands and subcommands
|
||||
//The add subcommand
|
||||
addCmd := cli.NewSubCommand("add", "adds file(s)/folder(s) (recursively for folder) to repo")
|
||||
@@ -123,7 +209,7 @@ func addCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
}
|
||||
if file != "" { // if the file flag was used it won't be empty
|
||||
fmt.Println("adding file to tracked files: ", file)
|
||||
err := clientcmd.AddFiles(file, "file", conf.Ignores)
|
||||
err := clientcmd.AddFiles(file, "file", conf.Ignores, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -131,7 +217,7 @@ func addCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
}
|
||||
if folder != "" { // if the folder flag was used it won't be empty
|
||||
fmt.Println("adding contents of folder to tracked files: ", folder)
|
||||
err := clientcmd.AddFiles(folder, "folder", conf.Ignores)
|
||||
err := clientcmd.AddFiles(folder, "folder", conf.Ignores, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -139,7 +225,7 @@ func addCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
}
|
||||
if wildcard != "" { // if the wildcard flag was used it won't be empty
|
||||
fmt.Println("adding files with wildcard filter: ", wildcard)
|
||||
err := clientcmd.AddFiles(wildcard, "wildcard", conf.Ignores)
|
||||
err := clientcmd.AddFiles(wildcard, "wildcard", conf.Ignores, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -149,40 +235,24 @@ func addCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
})
|
||||
|
||||
//Add all files recursively to repo
|
||||
addall := addCmd.NewSubCommand("all", "add all of the file(s)/folders(s) recursively to repo")
|
||||
addall := addCmd.NewSubCommand("all", "add all of the file(s)/folders(s) in root dir recursively to repo")
|
||||
addall.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(addall.OtherArgs()) > 0 {
|
||||
addCmd.PrintHelp()
|
||||
return fmt.Errorf("the 'all' subcommand does not accept additional arguments")
|
||||
}
|
||||
fmt.Println("adding all files recursively in directory to tracked files")
|
||||
err := clientcmd.AddFiles("", "all", conf.Ignores)
|
||||
err := clientcmd.AddFiles("", "all", conf.Ignores, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
//The add remote command
|
||||
remoteCmd := addCmd.NewSubCommand("remote", "add/delete/show remotes")
|
||||
var name string
|
||||
var host string
|
||||
var port int
|
||||
remoteAddCmd := remoteCmd.NewSubCommand("add", "add a remote, requires -name -host and -port")
|
||||
remoteAddCmd.LongDescription("Adds a remote to the .gvcconfig.toml. Requires the -name, -host and -port flags. Example: gvc remote add -name exampleRemote -host examplehost.com -port 8080")
|
||||
nameFlag := remoteAddCmd.StringFlag("name", "the name you want for your remote server", &name)
|
||||
nameFlag.FlagShortCut("name", "n")
|
||||
remoteAddCmd.FlagRequired("name")
|
||||
hostFlag := remoteAddCmd.StringFlag("host", "the hostname or IP Address of the remote", &host)
|
||||
hostFlag.FlagShortCut("host", "h")
|
||||
remoteAddCmd.FlagRequired("host")
|
||||
portFlag := remoteAddCmd.IntFlag("port", "the port the remote server is listening on", &port)
|
||||
portFlag.FlagShortCut("port", "p")
|
||||
remoteAddCmd.FlagRequired("port")
|
||||
remoteAddCmd.Action(func() error {
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func ignoreCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
@@ -211,16 +281,16 @@ func ignoreCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
return fmt.Errorf("incorrect input detected, please fix and retry")
|
||||
}
|
||||
if file != "" { // if the file flag was used it won't be empty
|
||||
fmt.Println("Ignoring file to tracked files: ", file)
|
||||
err := clientcmd.IgnoreFiles(file, "file", conf.Ignores)
|
||||
//fmt.Println("Ignoring file: ", file)
|
||||
err := clientcmd.IgnoreFiles(file, "file", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if folder != "" { // if the folder flag was used it won't be empty
|
||||
fmt.Println("Ignoring contents of folder to tracked files: ", folder)
|
||||
err := clientcmd.IgnoreFiles(folder, "folder", conf.Ignores)
|
||||
fmt.Println("Ignoring contents of folder: ", folder)
|
||||
err := clientcmd.IgnoreFiles(folder, "folder", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -228,7 +298,62 @@ func ignoreCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
}
|
||||
if wildcard != "" { // if the wildcard flag was used it won't be empty
|
||||
fmt.Println("Ignoring files with wildcard filter: ", wildcard)
|
||||
err := clientcmd.IgnoreFiles(wildcard, "wildcard", conf.Ignores)
|
||||
err := clientcmd.IgnoreFiles(wildcard, "wildcard", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// Adding the remove ignore command (remove from the ignore list)
|
||||
removeIgnoreCmd(ignoreCmd, conf)
|
||||
|
||||
}
|
||||
|
||||
// removeIgnoreCmd removes files/folders/wildcard from the ignore list
|
||||
func removeIgnoreCmd(ignoreCmd *clir.Command, conf *clientconfig.Gvcconfig) {
|
||||
removeIgnoreCmd := ignoreCmd.NewSubCommand("remove", "remove from ignores file(s)/folder(s) (recursively for folder) to repo")
|
||||
removeIgnoreCmd.LongDescription("You can remove from ignore all: all, a -file (-f): file.txt, or a -folder (-fd): folder, or a -wildcard (-wc): *.txt")
|
||||
//File/Folder/Wildcard Ignoring
|
||||
var file string
|
||||
var folder string
|
||||
var wildcard string
|
||||
fileFlag := removeIgnoreCmd.StringFlag("file", "removes ignored file from config", &file)
|
||||
fileFlag.FlagShortCut("file", "f")
|
||||
folderFlag := removeIgnoreCmd.StringFlag("folder", "removes ignored folder", &folder)
|
||||
folderFlag.FlagShortCut("folder", "fd")
|
||||
wildCardFlag := removeIgnoreCmd.StringFlag("wildcard", "removes wildcard from ignores", &wildcard)
|
||||
wildCardFlag.FlagShortCut("wildcard", "wc")
|
||||
removeIgnoreCmd.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(removeIgnoreCmd.OtherArgs()) > 0 {
|
||||
removeIgnoreCmd.PrintHelp()
|
||||
return fmt.Errorf("incorrect input detected, please fix and retry")
|
||||
}
|
||||
if file != "" { // if the file flag was used it won't be empty
|
||||
//fmt.Println("Ignoring file: ", file)
|
||||
err := clientcmd.RemoveIgnoreFiles(file, "file", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if folder != "" { // if the folder flag was used it won't be empty
|
||||
fmt.Println("Ignoring contents of folder: ", folder)
|
||||
err := clientcmd.RemoveIgnoreFiles(folder, "folder", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if wildcard != "" { // if the wildcard flag was used it won't be empty
|
||||
fmt.Println("Ignoring files with wildcard filter: ", wildcard)
|
||||
err := clientcmd.RemoveIgnoreFiles(wildcard, "wildcard", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -237,3 +362,360 @@ func ignoreCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func infoCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
//All the info commands
|
||||
infoCmd := cli.NewSubCommand("info", "tests various aspects of the client/files/etc and server")
|
||||
infoCmd.LongDescription("You can get information on remotes, files, etc")
|
||||
|
||||
remoteInfoCmd := infoCmd.NewSubCommand("remote", "takes the suppled server name and gets information about the server")
|
||||
remoteInfoCmd.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
var server string
|
||||
if len(remoteInfoCmd.OtherArgs()) == 0 { //Notify that we are using default server if none specified
|
||||
fmt.Println("No server specified, using default...")
|
||||
for _, remote := range conf.Remotes {
|
||||
if remote.Default {
|
||||
server = remote.Name
|
||||
}
|
||||
}
|
||||
} else { // Server name was specified, using that server
|
||||
server = remoteInfoCmd.OtherArgs()[0]
|
||||
}
|
||||
|
||||
connectionString, err := clientcmd.FindServer(server, "master", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = clientcmd.GetServerInfo(connectionString, conf.RepoName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// //File/Folder/Wildcard Ignoring
|
||||
// var file string
|
||||
// var folder string
|
||||
// var wildcard string
|
||||
// fileFlag := ignoreCmd.StringFlag("file", "adds a file to ignore to the config", &file)
|
||||
// fileFlag.FlagShortCut("file", "f")
|
||||
// folderFlag := ignoreCmd.StringFlag("folder", "tracks all contents of a folder to ignore", &folder)
|
||||
// folderFlag.FlagShortCut("folder", "fd")
|
||||
// wildCardFlag := ignoreCmd.StringFlag("wildcard", "treats the input as a wildcard and ignores all files that match the wildcard", &wildcard)
|
||||
// wildCardFlag.FlagShortCut("wildcard", "wc")
|
||||
// ignoreCmd.Action(func() error {
|
||||
// isRepo := validateRepo()
|
||||
// if !isRepo {
|
||||
// fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
// os.Exit(0)
|
||||
// }
|
||||
// if len(ignoreCmd.OtherArgs()) > 0 {
|
||||
// ignoreCmd.PrintHelp()
|
||||
// return fmt.Errorf("incorrect input detected, please fix and retry")
|
||||
// }
|
||||
// if file != "" { // if the file flag was used it won't be empty
|
||||
// //fmt.Println("Ignoring file: ", file)
|
||||
// err := clientcmd.IgnoreFiles(file, "file", conf)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
// if folder != "" { // if the folder flag was used it won't be empty
|
||||
// fmt.Println("Ignoring contents of folder: ", folder)
|
||||
// err := clientcmd.IgnoreFiles(folder, "folder", conf)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
// if wildcard != "" { // if the wildcard flag was used it won't be empty
|
||||
// fmt.Println("Ignoring files with wildcard filter: ", wildcard)
|
||||
// err := clientcmd.IgnoreFiles(wildcard, "wildcard", conf)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
// return nil
|
||||
// })
|
||||
}
|
||||
|
||||
func remoteCommands(cli *clir.Cli, conf *config.Gvcconfig) {
|
||||
//The add remote command
|
||||
remoteCmd := cli.NewSubCommand("remote", "add/delete/show remotes")
|
||||
var name string
|
||||
var host string
|
||||
var port int
|
||||
var defaultRemote bool
|
||||
remoteAddCmd := remoteCmd.NewSubCommand("add", "add a remote, requires -name -host and -port")
|
||||
remoteAddCmd.LongDescription("Adds a remote to the .gvcconfig.toml. Requires the -name, -host and -port flags. Example: gvc remote add -name exampleRemote -host examplehost.com -port 8080")
|
||||
nameFlag := remoteAddCmd.StringFlag("name", "the name you want for your remote server", &name)
|
||||
nameFlag.FlagShortCut("name", "n")
|
||||
remoteAddCmd.FlagRequired("name")
|
||||
hostFlag := remoteAddCmd.StringFlag("host", "the hostname or IP Address of the remote", &host)
|
||||
hostFlag.FlagShortCut("host", "h")
|
||||
remoteAddCmd.FlagRequired("host")
|
||||
portFlag := remoteAddCmd.IntFlag("port", "the port the remote server is listening on", &port)
|
||||
portFlag.FlagShortCut("port", "p")
|
||||
remoteAddCmd.FlagRequired("port")
|
||||
defaultFlag := remoteAddCmd.BoolFlag("default", "is used, the repo is set as default. (if first remote automatically set as default)", &defaultRemote)
|
||||
defaultFlag.FlagShortCut("default", "d")
|
||||
remoteAddCmd.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if name == "" || host == "" || port == 0 || port == 1 || port > 65535 {
|
||||
fmt.Println("incorrect input found, exiting, ensure you entered a valid port")
|
||||
os.Exit(0)
|
||||
}
|
||||
newRemotes, err := clientcmd.AddRemote(name, host, port, defaultRemote, conf.Remotes)
|
||||
conf.Remotes = newRemotes //Overwriting the old Remote list with new list
|
||||
if err != nil {
|
||||
return fmt.Errorf("error adding remote: %s", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func lockCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
|
||||
//All the lock commands and subcommands
|
||||
//The lock subcommand
|
||||
lockCmd := cli.NewSubCommand("lock", "locks file(s)/folder(s) (recursively for folder) to repo")
|
||||
lockCmd.LongDescription("You can lock all: all, a -file (-f): file.txt, or a -folder (-fd): folder, or a -wildcard (-wc): *.txt")
|
||||
//File/Folder/Wildcard Ignoring
|
||||
var file string
|
||||
var folder string
|
||||
var wildcard string
|
||||
fileFlag := lockCmd.StringFlag("file", "adds a file to lock to the config", &file)
|
||||
fileFlag.FlagShortCut("file", "f")
|
||||
folderFlag := lockCmd.StringFlag("folder", "tracks all contents of a folder to lock", &folder)
|
||||
folderFlag.FlagShortCut("folder", "fd")
|
||||
wildCardFlag := lockCmd.StringFlag("wildcard", "treats the input as a wildcard and locks all files that match the wildcard", &wildcard)
|
||||
wildCardFlag.FlagShortCut("wildcard", "wc")
|
||||
lockCmd.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(lockCmd.OtherArgs()) == 0 && file == "" && folder == "" && wildcard == "" { // if no input
|
||||
lockCmd.PrintHelp()
|
||||
return fmt.Errorf("please provide a file/folder/ext flag and name to be locked")
|
||||
}
|
||||
if len(lockCmd.OtherArgs()) > 1 {
|
||||
lockCmd.PrintHelp()
|
||||
return fmt.Errorf("incorrect input detected, please fix and retry")
|
||||
}
|
||||
if file != "" { // if the file flag was used it won't be empty
|
||||
//fmt.Println("Ignoring file: ", file)
|
||||
err := clientcmd.LockFiles(file, "file", conf)
|
||||
if err != nil {
|
||||
fmt.Println("error occurred locking file, attempting to roll back changes...")
|
||||
err := clientcmd.RemoveLockFiles(file, "file", conf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fatal error: unable to roll back lock file changes, issue with config: %s", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if folder != "" { // if the folder flag was used it won't be empty
|
||||
fmt.Println("Ignoring contents of folder: ", folder)
|
||||
err := clientcmd.LockFiles(folder, "folder", conf)
|
||||
if err != nil {
|
||||
err := clientcmd.RemoveLockFiles(folder, "folder", conf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fatal error: unable to roll back lock folder changes, issue with config: %s", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if wildcard != "" { // if the wildcard flag was used it won't be empty
|
||||
fmt.Println("Ignoring files with wildcard filter: ", wildcard)
|
||||
err := clientcmd.LockFiles(wildcard, "wildcard", conf)
|
||||
if err != nil {
|
||||
err := clientcmd.RemoveLockFiles(wildcard, "wildcard", conf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fatal error: unable to roll back lock wildcard changes, issue with config: %s", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// Adding the remove lock command (remove from the lock list)
|
||||
removeLockCmd(lockCmd, conf)
|
||||
}
|
||||
|
||||
// removeLockCmd removes files/folders/wildcard from the ignore list
|
||||
func removeLockCmd(ignoreCmd *clir.Command, conf *clientconfig.Gvcconfig) {
|
||||
removeLockCmd := ignoreCmd.NewSubCommand("remove", "remove from ignores file(s)/folder(s) (recursively for folder) to repo")
|
||||
removeLockCmd.LongDescription("You can remove from ignore all: all, a -file (-f): file.txt, or a -folder (-fd): folder, or a -wildcard (-wc): *.txt")
|
||||
//File/Folder/Wildcard Ignoring
|
||||
var file string
|
||||
var folder string
|
||||
var wildcard string
|
||||
fileFlag := removeLockCmd.StringFlag("file", "removes ignored file from config", &file)
|
||||
fileFlag.FlagShortCut("file", "f")
|
||||
folderFlag := removeLockCmd.StringFlag("folder", "removes ignored folder", &folder)
|
||||
folderFlag.FlagShortCut("folder", "fd")
|
||||
wildCardFlag := removeLockCmd.StringFlag("wildcard", "removes wildcard from ignores", &wildcard)
|
||||
wildCardFlag.FlagShortCut("wildcard", "wc")
|
||||
removeLockCmd.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(removeLockCmd.OtherArgs()) > 0 {
|
||||
removeLockCmd.PrintHelp()
|
||||
return fmt.Errorf("incorrect input detected, please fix and retry")
|
||||
}
|
||||
if file != "" { // if the file flag was used it won't be empty
|
||||
//fmt.Println("Ignoring file: ", file)
|
||||
err := clientcmd.RemoveLockFiles(file, "file", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if folder != "" { // if the folder flag was used it won't be empty
|
||||
fmt.Println("Ignoring contents of folder: ", folder)
|
||||
err := clientcmd.RemoveLockFiles(folder, "folder", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if wildcard != "" { // if the wildcard flag was used it won't be empty
|
||||
fmt.Println("Ignoring files with wildcard filter: ", wildcard)
|
||||
err := clientcmd.RemoveLockFiles(wildcard, "wildcard", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func branchCommand(cli *clir.Cli, conf *config.Gvcconfig) {
|
||||
branchCommand := cli.NewSubCommand("branch", "creates a new branch off of the current branch")
|
||||
var branchName string
|
||||
nameFlag := branchCommand.StringFlag("name", "name of the branch to create", &branchName)
|
||||
nameFlag.FlagShortCut("name", "n")
|
||||
nameFlag.FlagRequired("name")
|
||||
branchCommand.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
err := clientcmd.CreateBranch(conf, branchName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func switchCommand(cli *clir.Cli, conf *config.Gvcconfig) {
|
||||
switchCommand := cli.NewSubCommand("switch", "switches (and can create if needed) a new branch to work on")
|
||||
var createBranch bool
|
||||
createFlag := switchCommand.BoolFlag("create", "creates the branch if it does not exist", &createBranch)
|
||||
createFlag.FlagShortCut("create", "c")
|
||||
switchCommand.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if createBranch {
|
||||
if len(switchCommand.OtherArgs()) < 1 {
|
||||
switchCommand.PrintHelp()
|
||||
fmt.Println("branch name required..")
|
||||
os.Exit(0)
|
||||
}
|
||||
branchName := switchCommand.OtherArgs()[0]
|
||||
fmt.Println("attempting to create branch name: ", branchName)
|
||||
err := clientcmd.CreateBranch(conf, branchName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating branch: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if len(switchCommand.OtherArgs()) == 0 {
|
||||
switchCommand.PrintHelp()
|
||||
fmt.Println("branch name required..")
|
||||
os.Exit(0)
|
||||
}
|
||||
branchName := switchCommand.OtherArgs()[0]
|
||||
err := clientcmd.SwitchBranch(conf, branchName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to switch branch: %s", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func pullCommand(cli *clir.Cli, conf *config.Gvcconfig) {
|
||||
pullCommand := cli.NewSubCommand("pull", "pulls the latest commit from the server (default if none specified) on your current branch")
|
||||
var createBranch bool
|
||||
createFlag := pullCommand.BoolFlag("create", "creates the branch if it does not exist", &createBranch)
|
||||
createFlag.FlagShortCut("create", "c")
|
||||
pullCommand.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(pullCommand.OtherArgs()) == 0 {
|
||||
pullCommand.PrintHelp()
|
||||
fmt.Println("branch name required..")
|
||||
os.Exit(0)
|
||||
}
|
||||
branchName := pullCommand.OtherArgs()[0]
|
||||
err := clientcmd.SwitchBranch(conf, branchName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to pull branch: %s", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func commitCommand(cli *clir.Cli, conf *config.Gvcconfig, m *engine.Manager) {
|
||||
commitCommand := cli.NewSubCommand("commit", "commits the changes to the repo")
|
||||
var commitMessage string
|
||||
commitMessageFlag := commitCommand.StringFlag("message", "adds a message to a commit", &commitMessage)
|
||||
commitMessageFlag.FlagShortCut("message", "m")
|
||||
commitCommand.Action(func() error {
|
||||
isRepo := validateRepo()
|
||||
if !isRepo {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
// if len(commitCommand.OtherArgs()) == 0 {
|
||||
// commitCommand.PrintHelp()
|
||||
// fmt.Println("branch name required..")
|
||||
// os.Exit(0)
|
||||
// }
|
||||
if commitMessage != "" {
|
||||
|
||||
}
|
||||
err := clientcmd.Commit(conf, commitMessage, m)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to pull branch: %s", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@@ -6,10 +6,16 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
"github.com/deranjer/gvc/common"
|
||||
"github.com/deranjer/gvc/common/engine"
|
||||
)
|
||||
|
||||
//AddFiles adds files to the repo, inputType specifies file, folder, wildcard or all
|
||||
func AddFiles(input string, inputType string, ignore clientconfig.Ignore) error {
|
||||
func AddFiles(input string, inputType string, ignore common.FileTypes, m *engine.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
|
||||
}
|
||||
workingDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -21,13 +27,23 @@ func AddFiles(input string, inputType string, ignore clientconfig.Ignore) error
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to add file %s", err)
|
||||
}
|
||||
err = checkIgnores(input, "file", ignore)
|
||||
err = common.CheckFileTypes(input, "file", ignore)
|
||||
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?
|
||||
relativePath = "test.go"
|
||||
fmt.Println("Relative Path: ", relativePath)
|
||||
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)
|
||||
@@ -40,24 +56,37 @@ func AddFiles(input string, inputType string, ignore clientconfig.Ignore) error
|
||||
return fmt.Errorf("file exists, but is not a folder %s", err)
|
||||
}
|
||||
filepath.Walk(input, func(path string, info os.FileInfo, err error) error {
|
||||
currentFile := filepath.Base(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failure accessing path %s", err)
|
||||
}
|
||||
if info.IsDir() {
|
||||
err = checkIgnores(currentFile, "folder", ignore)
|
||||
if info.Name() == ".gvc" { // can't track anything in .gvc
|
||||
fmt.Println("skipping .gvc directory")
|
||||
m.Info().Msg("skipping .gvc directory")
|
||||
return filepath.SkipDir
|
||||
}
|
||||
err = common.CheckFileTypes(info.Name(), "folder", ignore)
|
||||
if err != nil {
|
||||
fmt.Printf("skipping ignored directory: %s\n", err)
|
||||
m.Info().Msgf("skipping ignored directory: %s\n", err)
|
||||
return filepath.SkipDir
|
||||
}
|
||||
} else {
|
||||
err = checkIgnores(currentFile, "file", ignore)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("Not adding file %s as it is on the ingores list \n", currentFile)
|
||||
return nil
|
||||
err = common.CheckFileTypes(info.Name(), "file", ignore)
|
||||
if err != nil {
|
||||
fmt.Printf("Not adding file %s as it is on the ingores list \n", info.Name())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fmt.Println("adding file: ", path)
|
||||
relativePath, err := filepath.Rel(workingDir, path)
|
||||
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
|
||||
})
|
||||
@@ -68,49 +97,80 @@ func AddFiles(input string, inputType string, ignore clientconfig.Ignore) error
|
||||
} else {
|
||||
wildcard = input
|
||||
}
|
||||
err := checkIgnores(wildcard, "wildcard", ignore)
|
||||
m.Info().Msgf("Adding all files with wildcard: %s", wildcard)
|
||||
err := common.CheckFileTypes(wildcard, "wildcard", ignore)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
filepath.Walk(workingDir, func(path string, info os.FileInfo, err error) error {
|
||||
currentFile := filepath.Base(path) // Stripping all the pathing so we just get the filename
|
||||
fmt.Println("path: ", path)
|
||||
fmt.Printf("Checking file: %s\n", info.Name())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failure accessing path %s", err)
|
||||
}
|
||||
if info.IsDir() {
|
||||
err = checkIgnores(currentFile, "folder", ignore)
|
||||
if info.Name() == ".gvc" { // can't track anything in .gvc
|
||||
fmt.Println("skipping .gvc directory")
|
||||
m.Info().Msg("skipping .gvc directory")
|
||||
return filepath.SkipDir
|
||||
}
|
||||
err = common.CheckFileTypes(info.Name(), "folder", ignore)
|
||||
if err != nil {
|
||||
fmt.Printf("skipping ignored directory: %s\n", err)
|
||||
m.Info().Msgf("skipping ignored directory: %s\n", err)
|
||||
return filepath.SkipDir
|
||||
}
|
||||
} else {
|
||||
err = checkIgnores(currentFile, "file", ignore)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("Not adding file %s as it is on the ingores list \n", currentFile)
|
||||
return nil
|
||||
err = common.CheckFileTypes(info.Name(), "file", ignore)
|
||||
if err != nil {
|
||||
fmt.Printf("Not adding file %s as it is on the ingores list \n", info.Name())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fileExt := filepath.Ext(path)
|
||||
if fileExt == wildcard { // seeing if the file ext matches the wildcard
|
||||
fmt.Println("Adding file that matched wildcard: ", currentFile)
|
||||
fmt.Println("Adding file that matched wildcard: ", info.Name())
|
||||
relativePath, err := filepath.Rel(workingDir, path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create relative path for file: %s", err)
|
||||
fmt.Printf("unable to create relative path for file: %s\n", err)
|
||||
m.Info().Msgf("unable to create relative path for file: %s\n", err)
|
||||
return nil
|
||||
}
|
||||
err = m.AddFileToRepo(relativePath)
|
||||
if err != nil {
|
||||
fmt.Printf("unable to add file to repo: %s\n", err)
|
||||
m.Info().Msgf("unable to add file to repo: %s\n", err)
|
||||
return nil
|
||||
}
|
||||
trackedFiles = append(trackedFiles, relativePath)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
case "all":
|
||||
m.Info().Msg("Adding all files...")
|
||||
filepath.Walk(workingDir, func(path string, info os.FileInfo, err error) error {
|
||||
currentFile := filepath.Base(path)
|
||||
if err != nil {
|
||||
fmt.Println("Err accessing path: ", err)
|
||||
return fmt.Errorf("failure accessing path %s", err)
|
||||
}
|
||||
if info.IsDir() {
|
||||
err = checkIgnores(currentFile, "folder", ignore)
|
||||
if info.Name() == ".gvc" { // can't track anything in .gvc
|
||||
fmt.Println("skipping .gvc directory")
|
||||
m.Info().Msg("skipping .gvc directory")
|
||||
return filepath.SkipDir
|
||||
}
|
||||
err = common.CheckFileTypes(info.Name(), "folder", ignore)
|
||||
if err != nil {
|
||||
fmt.Printf("skipping ignored directory: %s\n", err)
|
||||
m.Info().Msgf("skipping ignored directory: %s\n", err)
|
||||
return filepath.SkipDir
|
||||
}
|
||||
} else {
|
||||
err = checkIgnores(currentFile, "file", ignore)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("Not adding file %s as it is on the ingores list \n", currentFile)
|
||||
return nil
|
||||
err = common.CheckFileTypes(info.Name(), "file", ignore)
|
||||
if err != nil {
|
||||
fmt.Printf("Not adding file %s as it is on the ingores list \n", info.Name())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
relativePath, err := filepath.Rel(workingDir, path)
|
||||
if err != nil {
|
||||
@@ -119,16 +179,38 @@ func AddFiles(input string, inputType string, ignore clientconfig.Ignore) error
|
||||
if relativePath == "." { //Ignoring current directory
|
||||
return nil
|
||||
}
|
||||
fmt.Println("Adding file to repo: ", path)
|
||||
m.Info().Msgf("Adding file to repo: %s", path)
|
||||
err = m.AddFileToRepo(relativePath)
|
||||
if err != nil {
|
||||
fmt.Printf("unable to add file to repo: %s\n", err)
|
||||
return nil
|
||||
}
|
||||
trackedFiles = append(trackedFiles, relativePath)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
fmt.Println("Added tracked files", trackedFiles) // Print out all the new tracked files
|
||||
if len(trackedFiles) > 0 {
|
||||
fmt.Println("Added tracked files", trackedFiles) // Print out all the new tracked files
|
||||
m.Info().Msgf("Adding the following files to tracked: %s", trackedFiles)
|
||||
} else {
|
||||
fmt.Println("No files found that could be added to tracked")
|
||||
m.Info().Msg("No files found that could be added to tracked")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddRemote adds a remote to the config file
|
||||
func AddRemote(name string, host string, port int, conf *clientconfig.Gvcconfig) error {
|
||||
fmt.Println("name: ", name, "host: ", host, "port: ", port)
|
||||
// checkRemotesSlice just ranges through the remotes looking for duplicates
|
||||
func checkRemotesSlice(name, host string, port int, remotes []clientconfig.Remote) error {
|
||||
for _, remote := range remotes { // Names of remotes must be unique so make sure they are
|
||||
if name == remote.Name {
|
||||
return fmt.Errorf("remote with that name already exits: %s", name)
|
||||
}
|
||||
}
|
||||
for _, remote := range remotes { // make sure we don't have another remote with same host and port
|
||||
if host == remote.Host && port == remote.Port {
|
||||
return fmt.Errorf("remote with that host and port config already exists: %s:%d", host, port)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
25
client/clientcmd/branch.go
Normal file
25
client/clientcmd/branch.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package clientcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
)
|
||||
|
||||
// CreateBranch creates a new branch with the supplied name
|
||||
func CreateBranch(conf *clientconfig.Gvcconfig, branchName string) error {
|
||||
branches := conf.LocalBranches
|
||||
for _, branch := range branches {
|
||||
if branch == branchName {
|
||||
return fmt.Errorf("Branch already exists, unable to create, use the switch command to switch to this branch: %s", branchName)
|
||||
}
|
||||
}
|
||||
conf.LocalBranches = append(conf.LocalBranches, branchName) //add the branch to the config
|
||||
// TODO Create the branch
|
||||
//If success, switch to new branch
|
||||
err := SwitchBranch(conf, branchName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error switching to new branch: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
18
client/clientcmd/commit.go
Normal file
18
client/clientcmd/commit.go
Normal file
@@ -0,0 +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 {
|
||||
err := m.BeginCommit(conf.CurrentBranch, commitMessage)
|
||||
if err != nil {
|
||||
return fmt.Errorf("begin commit failed with message: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@@ -2,7 +2,9 @@ package clientcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
)
|
||||
@@ -10,32 +12,48 @@ import (
|
||||
// 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)
|
||||
}
|
||||
func validateFileType(path string, inputType string) error {
|
||||
if inputType == "wildcard" { // Can't stat wildcard type
|
||||
return nil
|
||||
}
|
||||
fullPath, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot stat file, invalid input? %s", err)
|
||||
}
|
||||
fileInfo, err := os.Stat(fullPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read file, corrupted? %s", err)
|
||||
}
|
||||
if fileInfo.IsDir() {
|
||||
if inputType == "folder" || inputType == "all" {
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("folder flag was used, but input is not a folder, will not continue")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindServer finds the supplied server connection settings, creates a connection string and returns it
|
||||
func FindServer(serverName string, branchName string, conf *clientconfig.Gvcconfig) (connectionString string, err error) {
|
||||
if branchName == "" { // If no branch listed select master TODO: in future the 'default' branch will be their current branch
|
||||
branchName = "master"
|
||||
}
|
||||
if serverName == "" { // if no serverName is specified, just use the default
|
||||
for _, remote := range conf.Remotes {
|
||||
if remote.Default {
|
||||
serverName = remote.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, remote := range conf.Remotes {
|
||||
if serverName == remote.Name {
|
||||
fmt.Printf("Server found in config, connecting to: %s, host: %s, port: %d \n", remote.Name, remote.Host, remote.Port)
|
||||
port := ":" + strconv.Itoa(remote.Port)
|
||||
connectionString := "http://" + remote.Host + port //Create our connection string //'http://server:port'
|
||||
fmt.Println("Generated connection string: ", connectionString)
|
||||
return connectionString, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("unable to find server name in config")
|
||||
}
|
||||
|
@@ -2,13 +2,110 @@ package clientcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
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, ignore clientconfig.Ignore) error {
|
||||
fmt.Println("File/folder/wildcard to ignore", os.Args[2])
|
||||
return nil
|
||||
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 //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 := common.CheckFileTypes(input, "file", ignore)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s already ignored: %s", input, err)
|
||||
}
|
||||
fmt.Println("Adding file to ignores: ", input)
|
||||
conf.Ignores.Files = append(conf.Ignores.Files, input)
|
||||
return nil
|
||||
case "folder":
|
||||
err := common.CheckFileTypes(input, "folder", ignore)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s is already ignored: %s", input, err)
|
||||
}
|
||||
fmt.Println("Adding folder to ignores: ", input)
|
||||
conf.Ignores.Folders = append(conf.Ignores.Folders, input)
|
||||
return nil
|
||||
case "wildcard":
|
||||
var wildcard string
|
||||
if input[:1] == "*" { // Removing the wildcard char since we don't store that or test with that char
|
||||
wildcard = input[1:]
|
||||
} else {
|
||||
wildcard = input
|
||||
}
|
||||
err := common.CheckFileTypes(wildcard, "wildcard", ignore)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s is already ignored: %s", input, err)
|
||||
}
|
||||
fmt.Println("Adding wildcard to ignores: ", wildcard)
|
||||
conf.Ignores.Exts = append(conf.Ignores.Exts, wildcard)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("This... should not have happened, some kind of internal error on IgnoreFiles function call, switch failure")
|
||||
}
|
||||
|
||||
// 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 //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 := common.CheckFileTypes(input, "file", ignore)
|
||||
if err != nil {
|
||||
fmt.Println("Removing file from ignores: ", input)
|
||||
for i, fileIgnore := range ignore.Files {
|
||||
if input == fileIgnore {
|
||||
conf.Ignores.Files[i] = conf.Ignores.Files[len(conf.Ignores.Files)-1] // Deleting the element
|
||||
conf.Ignores.Files = conf.Ignores.Files[:len(conf.Ignores.Files)-1] // redoing the slice
|
||||
fmt.Println("Removing file from ignores: ", input)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("File not found in ingores, unable to remove: ", input)
|
||||
return nil
|
||||
case "folder":
|
||||
err := common.CheckFileTypes(input, "folder", ignore)
|
||||
if err != nil {
|
||||
for i, folderIgnore := range ignore.Folders {
|
||||
if input == folderIgnore {
|
||||
conf.Ignores.Folders[i] = conf.Ignores.Folders[len(conf.Ignores.Folders)-1]
|
||||
conf.Ignores.Folders = conf.Ignores.Files[:len(conf.Ignores.Folders)-1]
|
||||
fmt.Println("Removing folder from ignores: ", input)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("Folder not found in ingores, unable to remove: ", input)
|
||||
return nil
|
||||
case "wildcard":
|
||||
var wildcard string
|
||||
if input[:1] == "*" { // Removing the wildcard char since we don't store that or test with that char
|
||||
wildcard = input[1:]
|
||||
} else {
|
||||
wildcard = input
|
||||
}
|
||||
err := common.CheckFileTypes(wildcard, "wildcard", ignore)
|
||||
if err != nil {
|
||||
for i, wildcardIgnore := range ignore.Exts {
|
||||
if input == wildcardIgnore {
|
||||
conf.Ignores.Exts[i] = conf.Ignores.Exts[len(conf.Ignores.Exts)-1]
|
||||
conf.Ignores.Exts = conf.Ignores.Exts[:len(conf.Ignores.Exts)-1]
|
||||
fmt.Println("Removing wildcard from ignores: ", wildcard)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("Wildcard not found in ingores, unable to remove: ", wildcard)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("This... should not have happened, some kind of internal error on RemoveIgnoreFiles function call, switch failure")
|
||||
}
|
||||
|
28
client/clientcmd/info.go
Normal file
28
client/clientcmd/info.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package clientcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
// GetServerInfo queries the supplied connection string for server info and uses the provided repoName to get repo specific information
|
||||
func GetServerInfo(connectionString string, repoName string) error {
|
||||
client := resty.New()
|
||||
resp, err := client.R().
|
||||
SetPathParams(map[string]string{
|
||||
"repoName": repoName,
|
||||
}).
|
||||
Get(connectionString + "/info/" + "{repoName}") //creating the full string to get info
|
||||
if err != nil {
|
||||
return fmt.Errorf("error connecting to server at: %s: error was: %s", connectionString, err)
|
||||
}
|
||||
if resp.IsError() {
|
||||
if resp.StatusCode() == 404 {
|
||||
return fmt.Errorf("repo was not found on server, 404: %s", resp.Request.URL)
|
||||
}
|
||||
return fmt.Errorf("response not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL)
|
||||
}
|
||||
fmt.Println(resp)
|
||||
return nil
|
||||
}
|
@@ -2,19 +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() {
|
||||
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\n")
|
||||
}
|
||||
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
|
||||
}
|
||||
fmt.Println("Adding new repo with name: ", repoName)
|
||||
return repoName, nil
|
||||
}
|
||||
|
148
client/clientcmd/lock.go
Normal file
148
client/clientcmd/lock.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package clientcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
clientconfig "github.com/deranjer/gvc/client/clientconfig"
|
||||
"github.com/deranjer/gvc/common"
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
//LockFiles locks file(s)/folder based on name/wildcard, etc
|
||||
func LockFiles(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
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
locked := conf.Locked
|
||||
connectionString, err := FindServer("", conf.CurrentBranch, conf) //TODO: Maybe allow user to specify lock server? Seems like they should just use the default server though
|
||||
switch inputType { // TODO: add default case for generic error handling // TODO: there is no user supplied input here, so WHY?
|
||||
case "file":
|
||||
err := common.CheckFileTypes(input, "file", locked)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s already locked: %s", input, err)
|
||||
}
|
||||
fmt.Println("Adding file to locked: ", input)
|
||||
conf.Locked.Files = append(conf.Locked.Files, input)
|
||||
err = SendLockToServer(connectionString, conf.RepoName, "file", input)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error sending lock to server: %s", err)
|
||||
}
|
||||
return nil
|
||||
case "folder":
|
||||
err := common.CheckFileTypes(input, "folder", locked)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s is already locked: %s", input, err)
|
||||
}
|
||||
fmt.Println("Adding folder to locked: ", input)
|
||||
conf.Locked.Folders = append(conf.Locked.Folders, input)
|
||||
err = SendLockToServer(connectionString, conf.RepoName, "folder", input)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error sending lock to server: %s", err)
|
||||
}
|
||||
return nil
|
||||
case "wildcard":
|
||||
var wildcard string
|
||||
if input[:1] == "*" { // Removing the wildcard char since we don't store that or test with that char
|
||||
wildcard = input[1:]
|
||||
} else {
|
||||
wildcard = input
|
||||
}
|
||||
err := common.CheckFileTypes(wildcard, "wildcard", locked)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s is already locked: %s", input, err)
|
||||
}
|
||||
fmt.Println("Adding wildcard to locked: ", wildcard)
|
||||
conf.Locked.Exts = append(conf.Locked.Exts, wildcard)
|
||||
err = SendLockToServer(connectionString, conf.RepoName, "wildcard", input)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error sending lock to server: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("This... should not have happened, some kind of internal error on LockFiles function call, switch failure")
|
||||
}
|
||||
|
||||
// RemoveLockFiles removes files/folders/wildcards from the locked list
|
||||
func RemoveLockFiles(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
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
locked := conf.Locked
|
||||
switch inputType { // TODO: add default case for generic error handling
|
||||
case "file":
|
||||
err := common.CheckFileTypes(input, "file", locked)
|
||||
if err != nil {
|
||||
fmt.Println("Removing file from locked: ", input)
|
||||
for i, fileLock := range locked.Files {
|
||||
if input == fileLock {
|
||||
conf.Locked.Files[i] = conf.Locked.Files[len(conf.Locked.Files)-1] // Deleting the element
|
||||
conf.Locked.Files = conf.Locked.Files[:len(conf.Locked.Files)-1] // redoing the slice
|
||||
fmt.Println("Removing file from locked: ", input)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("File not found in ingores, unable to remove: ", input)
|
||||
return nil
|
||||
case "folder":
|
||||
err := common.CheckFileTypes(input, "folder", locked)
|
||||
if err != nil {
|
||||
for i, folderLock := range locked.Folders {
|
||||
if input == folderLock {
|
||||
conf.Locked.Folders[i] = conf.Locked.Folders[len(conf.Locked.Folders)-1]
|
||||
conf.Locked.Folders = conf.Locked.Files[:len(conf.Locked.Folders)-1]
|
||||
fmt.Println("Removing folder from locked: ", input)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("Folder not found in ingores, unable to remove: ", input)
|
||||
return nil
|
||||
case "wildcard":
|
||||
var wildcard string
|
||||
if input[:1] == "*" { // Removing the wildcard char since we don't store that or test with that char
|
||||
wildcard = input[1:]
|
||||
} else {
|
||||
wildcard = input
|
||||
}
|
||||
err := common.CheckFileTypes(wildcard, "wildcard", locked)
|
||||
if err != nil {
|
||||
for i, wildcardLock := range locked.Exts {
|
||||
if input == wildcardLock {
|
||||
conf.Locked.Exts[i] = conf.Locked.Exts[len(conf.Locked.Exts)-1]
|
||||
conf.Locked.Exts = conf.Locked.Exts[:len(conf.Locked.Exts)-1]
|
||||
fmt.Println("Removing wildcard from locked: ", wildcard)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("Wildcard not found in ingores, unable to remove: ", wildcard)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("This... should not have happened, some kind of internal error on RemoveLockFiles function call, switch failure")
|
||||
}
|
||||
|
||||
// SendLockToServer sends an updated lock file to the server
|
||||
func SendLockToServer(connectionString string, repoName string, fileType string, fileName string) error {
|
||||
client := resty.New()
|
||||
resp, err := client.R().
|
||||
SetPathParams(map[string]string{
|
||||
"repoName": repoName,
|
||||
"type": fileType,
|
||||
"name": fileName,
|
||||
}).
|
||||
Get(connectionString + "/lock/" + "{repoName}/" + "{type}/" + "{name}") //creating the full string to get info
|
||||
if err != nil {
|
||||
return fmt.Errorf("error connecting to server at: %s: error was: %s", connectionString, err)
|
||||
}
|
||||
if resp.IsError() {
|
||||
if resp.StatusCode() == 404 {
|
||||
return fmt.Errorf("error: repo was not found on server, 404: %s", resp.Request.URL)
|
||||
}
|
||||
return fmt.Errorf("%s: response code: %d: %s", resp.Request.URL, resp.StatusCode(), resp)
|
||||
}
|
||||
fmt.Println(resp)
|
||||
return nil
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user