diff --git a/client/.gvc/gvc.db b/client/.gvc/gvc.db index e30e954..7038b28 100644 Binary files a/client/.gvc/gvc.db and b/client/.gvc/gvc.db differ diff --git a/client/.gvc/logs/gvclog.log b/client/.gvc/logs/gvclog.log index 90cfe3b..2e118d8 100644 --- a/client/.gvc/logs/gvclog.log +++ b/client/.gvc/logs/gvclog.log @@ -243,3 +243,62 @@ {"level":"error","module":"database","error":"already exists","message":"Error initialising file in database"} {"level":"error","message":"Error checking if file [test.go] is monitored. Error already exists"} {"level":"info","message":"Adding the following files to tracked: [client.go clientcmd\\add.go clientcmd\\branch.go clientcmd\\commit.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.old test\\test2.go]"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: test commit"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: test commit"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: master"} +{"level":"info","message":"Total number of files to commit: %!s(int=16)"} +{"level":"info","module":"database","message":"Writing new commit: %!s(int=1) on branch: master"} +{"level":"error","module":"database","error":"provided target must be a pointer to struct","message":"failure to write commit to database"} +{"level":"error","error":"provided target must be a pointer to struct","message":"unable to create initial commit: provided target must be a pointer to struct"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: master"} +{"level":"info","message":"Total number of files to commit: %!s(int=16)"} +{"level":"info","module":"database","message":"Writing new commit: %!s(int=1) on branch: master"} +{"level":"error","module":"database","error":"missing struct tag id or ID field","message":"failure to write commit to database"} +{"level":"error","error":"missing struct tag id or ID field","message":"unable to create initial commit: missing struct tag id or ID field"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"error","module":"database","error":"not found","message":"Failed to find last commit on branch: master"} +{"level":"info","message":"unable to fetch last commit on branch, assuming first commit on branch%!(EXTRA *errors.errorString=not found)"} +{"level":"info","message":"Starting initial commit on branch: master"} +{"level":"info","message":"Total number of files to commit: %!s(int=16)"} +{"level":"info","module":"database","message":"Writing new commit: %!s(int=1) on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} +{"level":"info","message":"Creating new Manager..."} +{"level":"info","module":"database","message":"Fetching last commit on branch: master"} diff --git a/client/.gvc/objects/05427e82646f4b87e5117cc66b2ed7c7560871283cacd2ad1361e3796cb30ddd/add.go b/client/.gvc/objects/05427e82646f4b87e5117cc66b2ed7c7560871283cacd2ad1361e3796cb30ddd/add.go new file mode 100644 index 0000000..1176a20 Binary files /dev/null and b/client/.gvc/objects/05427e82646f4b87e5117cc66b2ed7c7560871283cacd2ad1361e3796cb30ddd/add.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/add.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/add.go new file mode 100644 index 0000000..1176a20 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/add.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/branch.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/branch.go new file mode 100644 index 0000000..1ee98f5 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/branch.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/client.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/client.go new file mode 100644 index 0000000..8898e79 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/client.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/commit.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/commit.go new file mode 100644 index 0000000..3366932 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/commit.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/commonlib.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/commonlib.go new file mode 100644 index 0000000..92a23b6 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/commonlib.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/config.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/config.go new file mode 100644 index 0000000..326fd60 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/config.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/ignore.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/ignore.go new file mode 100644 index 0000000..3d7d4ef Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/ignore.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/info.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/info.go new file mode 100644 index 0000000..179c3e7 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/info.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/init.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/init.go new file mode 100644 index 0000000..7af3289 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/init.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/lock.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/lock.go new file mode 100644 index 0000000..ba76ca6 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/lock.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/refresh.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/refresh.go new file mode 100644 index 0000000..9c17618 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/refresh.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/remote.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/remote.go new file mode 100644 index 0000000..514e36b Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/remote.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/structures.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/structures.go new file mode 100644 index 0000000..2b061e4 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/structures.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/switch.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/switch.go new file mode 100644 index 0000000..5992dd7 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/switch.go differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/test.go.old b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/test.go.old new file mode 100644 index 0000000..0e9c8c8 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/test.go.old differ diff --git a/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/test2.go b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/test2.go new file mode 100644 index 0000000..15f7253 Binary files /dev/null and b/client/.gvc/objects/09d45446b989dcc64a83e457f8471eb2faf16a55ecfb5e65e6c20ba632c7a8c4/test2.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/add.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/add.go new file mode 100644 index 0000000..1176a20 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/add.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/branch.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/branch.go new file mode 100644 index 0000000..1ee98f5 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/branch.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/client.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/client.go new file mode 100644 index 0000000..8898e79 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/client.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/commit.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/commit.go new file mode 100644 index 0000000..3366932 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/commit.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/commonlib.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/commonlib.go new file mode 100644 index 0000000..92a23b6 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/commonlib.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/config.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/config.go new file mode 100644 index 0000000..326fd60 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/config.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/ignore.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/ignore.go new file mode 100644 index 0000000..3d7d4ef Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/ignore.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/info.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/info.go new file mode 100644 index 0000000..179c3e7 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/info.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/init.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/init.go new file mode 100644 index 0000000..7af3289 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/init.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/lock.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/lock.go new file mode 100644 index 0000000..ba76ca6 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/lock.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/refresh.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/refresh.go new file mode 100644 index 0000000..9c17618 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/refresh.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/remote.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/remote.go new file mode 100644 index 0000000..514e36b Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/remote.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/structures.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/structures.go new file mode 100644 index 0000000..2b061e4 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/structures.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/switch.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/switch.go new file mode 100644 index 0000000..5992dd7 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/switch.go differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/test.go.old b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/test.go.old new file mode 100644 index 0000000..0e9c8c8 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/test.go.old differ diff --git a/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/test2.go b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/test2.go new file mode 100644 index 0000000..15f7253 Binary files /dev/null and b/client/.gvc/objects/45d0ec3eabe1cbb5901256d0cecf9f779460232c465528a1d351987d8f31208b/test2.go differ diff --git a/client/.gvc/objects/d2243741cf8fa88a93092b2f8783a06da337ec91dcf25620aa5ba5c9fd231170/add.go b/client/.gvc/objects/d2243741cf8fa88a93092b2f8783a06da337ec91dcf25620aa5ba5c9fd231170/add.go new file mode 100644 index 0000000..1176a20 Binary files /dev/null and b/client/.gvc/objects/d2243741cf8fa88a93092b2f8783a06da337ec91dcf25620aa5ba5c9fd231170/add.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/add.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/add.go new file mode 100644 index 0000000..1176a20 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/add.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/branch.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/branch.go new file mode 100644 index 0000000..1ee98f5 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/branch.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/client.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/client.go new file mode 100644 index 0000000..8898e79 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/client.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/commit.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/commit.go new file mode 100644 index 0000000..3366932 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/commit.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/commonlib.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/commonlib.go new file mode 100644 index 0000000..92a23b6 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/commonlib.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/config.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/config.go new file mode 100644 index 0000000..326fd60 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/config.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/ignore.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/ignore.go new file mode 100644 index 0000000..3d7d4ef Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/ignore.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/info.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/info.go new file mode 100644 index 0000000..179c3e7 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/info.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/init.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/init.go new file mode 100644 index 0000000..7af3289 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/init.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/lock.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/lock.go new file mode 100644 index 0000000..ba76ca6 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/lock.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/refresh.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/refresh.go new file mode 100644 index 0000000..9c17618 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/refresh.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/remote.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/remote.go new file mode 100644 index 0000000..514e36b Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/remote.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/structures.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/structures.go new file mode 100644 index 0000000..2b061e4 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/structures.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/switch.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/switch.go new file mode 100644 index 0000000..5992dd7 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/switch.go differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/test.go.old b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/test.go.old new file mode 100644 index 0000000..0e9c8c8 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/test.go.old differ diff --git a/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/test2.go b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/test2.go new file mode 100644 index 0000000..15f7253 Binary files /dev/null and b/client/.gvc/objects/f55f3a3d475537bd7ec2dcf6789acf205cfadcba62bfed918433017392c111f7/test2.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/add.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/add.go new file mode 100644 index 0000000..1176a20 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/add.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/branch.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/branch.go new file mode 100644 index 0000000..1ee98f5 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/branch.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/client.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/client.go new file mode 100644 index 0000000..8898e79 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/client.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/commit.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/commit.go new file mode 100644 index 0000000..3366932 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/commit.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/commonlib.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/commonlib.go new file mode 100644 index 0000000..92a23b6 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/commonlib.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/config.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/config.go new file mode 100644 index 0000000..326fd60 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/config.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/ignore.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/ignore.go new file mode 100644 index 0000000..3d7d4ef Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/ignore.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/info.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/info.go new file mode 100644 index 0000000..179c3e7 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/info.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/init.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/init.go new file mode 100644 index 0000000..7af3289 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/init.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/lock.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/lock.go new file mode 100644 index 0000000..ba76ca6 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/lock.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/refresh.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/refresh.go new file mode 100644 index 0000000..9c17618 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/refresh.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/remote.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/remote.go new file mode 100644 index 0000000..514e36b Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/remote.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/structures.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/structures.go new file mode 100644 index 0000000..2b061e4 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/structures.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/switch.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/switch.go new file mode 100644 index 0000000..5992dd7 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/switch.go differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/test.go.old b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/test.go.old new file mode 100644 index 0000000..0e9c8c8 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/test.go.old differ diff --git a/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/test2.go b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/test2.go new file mode 100644 index 0000000..15f7253 Binary files /dev/null and b/client/.gvc/objects/f659b2336d67e18f3cf4f674443f8b38cb8bf405b0b5a69340fb4d0ba3137cd7/test2.go differ diff --git a/common/database/db-ops.go b/common/database/db-ops.go index 4831ad0..292a849 100644 --- a/common/database/db-ops.go +++ b/common/database/db-ops.go @@ -88,7 +88,7 @@ func (db *DB) UpdateFileData(filePath, basePath string, hash []byte) error { db.Err(err).Msg("Error updating the file base") return err } else { - err := db.Update(&File{ID: file.ID, CurrentBase: basePath, Hash: hash}) + err := db.Update(&File{ID: file.ID, BaseFilePath: basePath, Hash: hash}) return err } } @@ -198,6 +198,18 @@ func (db *DB) FetchLastCommitOnBranch(branch string) (commitResult Commit, err e err = query.OrderBy("Number").Reverse().First(&commit) // Getting the last entry by number if err != nil { db.Err(err).Msgf("Failed to find last commit on branch: %s", branch) + return commit, err } return commit, nil } + +// NewCommit writes a new commit to the specified branch into the database +func (db *DB) NewCommit(newCommit Commit, branch string) error { + db.Info().Msgf("Writing new commit: %s on branch: %s", newCommit.Number, branch) + err := db.Save(&newCommit) + if err != nil { + db.Err(err).Msg("failure to write commit to database") + return err + } + return nil +} diff --git a/common/database/structures.go b/common/database/structures.go index ff92a2c..964a1ae 100644 --- a/common/database/structures.go +++ b/common/database/structures.go @@ -24,7 +24,7 @@ type GVCInfo struct { // Commit stores all the necessary information for a commit type Commit struct { - CommitHash []byte `storm:"index,unique"` // The hash of the commit (generated by hashing commit author name, time, the previous commit, and more? TODO: Not sure what else) + CommitHash []byte `storm:"id,index,unique"` // The hash of the commit (generated by hashing commit author name, time, the previous commit, and more? TODO: Not sure what else) TrackedFiles []File // All of the tracked files for this commit Date string Version string //User can tag a commit with a version number @@ -43,19 +43,19 @@ type CommitMeta struct { // File represents a tracked file type File struct { - ID int `storm:"id,increment"` - Path string `storm:"index"` - Name string - //BkpLocation string //TODO: Needed? - CurrentBase string - Hash []byte `storm:"index,unique"` // with []byte can't use sha256.sum256 since that is [32]byte, so everything done manually. - CreatedAt time.Time - Unique string - Version float64 - NoCompress bool // Whether or not to compress this file + ID int `storm:"id,increment"` + Path string `storm:"index"` + BaseFilePath string // This stores the path to the tracked version of the file in the object database + Name string + //CurrentBase string + Hash []byte `storm:"index,unique"` // with []byte can't use sha256.sum256 since that is [32]byte, so everything done manually. + CreatedAt time.Time + Unique string + Version float64 + NoCompress bool // Whether or not to compress this file } -// CalculateHash creates a hash for the file +// CalculateHash creates a hash for the file //Requires path func (f *File) CalculateHash() error { fileContents, err := ioutil.ReadFile(f.Path) if err != nil { diff --git a/common/engine/commits.go b/common/engine/commits.go index 68f285a..d9a33fc 100644 --- a/common/engine/commits.go +++ b/common/engine/commits.go @@ -11,7 +11,8 @@ import ( ) // CreateInitialCommit copies the files over and compresses them if they are not in the NoCompress struct -func (m *Manager) CreateInitialCommit(fileList []database.File, commitMessage string) error { // ONLY HAPPENS FOR MASTER I THINK, SO NO BRANCH NEEDED +func (m *Manager) CreateInitialCommit(fileList []database.File, branch string, commitMessage string) error { // ONLY HAPPENS FOR MASTER I THINK, SO NO BRANCH NEEDED + m.Info().Msgf("Starting initial commit on branch: %s", branch) //Need to deduplicate so we aren't storing duplicates of files, storing all the files in one folder won't work, will need something like git //For initial commit no changes are made to files, so don't store anything, just save the list so you can send to server var initialCommit database.Commit @@ -30,8 +31,19 @@ func (m *Manager) CreateInitialCommit(fileList []database.File, commitMessage st if err != nil { return fmt.Errorf("unable to create commit directory in object dir: %s err: %s", folder, err) } + m.Info().Msgf("Total number of files to commit: %s", len(fileList)) + fmt.Println("Total number of files to commit: ", len(fileList)) for _, file := range fileList { - ConvertFileForStorage(&file, folder) + filename, err := ConvertFileForStorage(&file, folder) + if err != nil { + // TODO: roll back commit on error (folders/files created need to be deleted) + return err + } + file.BaseFilePath = filename + } + err = m.dB.NewCommit(initialCommit, branch) + if err != nil { + return err } //var hashList [][]byte return nil diff --git a/common/engine/compressor.go b/common/engine/compressor.go index ecddf78..6227bff 100644 --- a/common/engine/compressor.go +++ b/common/engine/compressor.go @@ -2,10 +2,14 @@ package engine import ( "bytes" - "compress/gzip" + "io/ioutil" + "os" + "encoding/gob" "fmt" "io" + + gzip "github.com/klauspost/pgzip" ) type SomeStruct struct { @@ -14,6 +18,51 @@ type SomeStruct struct { C float64 } +// CompressFile uses pgzip to compress a file for storage +func CompressFile(path string) error { + fileBytes, err := ioutil.ReadFile(path) + if err != nil { + return fmt.Errorf("unable to read file: %s", path) + } + file, err := os.Create(path) + if err != nil { + return err + } + w := gzip.NewWriter(file) + w.SetConcurrency(100000, 10) + bytesWritten, err := w.Write(fileBytes) + if err != nil { + return err + } + fmt.Println("%d Bytes Written", bytesWritten) + w.Close() + return nil +} + +// RestoreFile takes the compressed file path and the target path and decompresses the file into the target path +func RestoreFile(compressPath, targetPath string) error { + fileBytes, err := os.Open(compressPath) + if err != nil { + return fmt.Errorf("unable to read file: %s", compressPath) + } + err = os.Remove(targetPath) + if err != nil { + return fmt.Errorf("unable to remove target file to replace with decompressed file: %s", targetPath) + } + file, err := os.Create(targetPath) + if err != nil { + return err + } + r, err := gzip.NewReader(fileBytes) + bytesWritten, err := r.WriteTo(file) + if err != nil { + return err + } + fmt.Println("%d Bytes Written", bytesWritten) + r.Close() + return nil +} + //1. func StructToBytes(obj SomeStruct) (bytes.Buffer, error) { //now gob this diff --git a/common/engine/filesystem.go b/common/engine/filesystem.go index 18fb168..4b5d864 100644 --- a/common/engine/filesystem.go +++ b/common/engine/filesystem.go @@ -5,7 +5,6 @@ import ( "compress/gzip" "encoding/binary" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -68,19 +67,15 @@ func ExpandToIntArray(length int64, arry []byte, intArray *[]int64) error { // return fileName, nil // } -func ConvertFileForStorage(file *database.File, folder string) error { - fileBytes, err := ioutil.ReadFile(file.Path) +// ConvertFileForStorage opens the original file and dumps the bytes to pgzip to compress it for storage +func ConvertFileForStorage(file *database.File, folder string) (fileName string, err error) { + filename := folder + string(filepath.Separator) + file.Name //fileName is under the object folder then the hash, then the filename + err = CompressFile(filename) if err != nil { - return err + return filename, err } - fmt.Println("REMOVE: ", fileBytes) - filename := folder + string(filepath.Separator) + file.Name - err = ioutil.WriteFile(filename, fileBytes, 0666) - if err != nil { - return err - } - return nil - + fmt.Println("Compressed and written", file.Path) + return filename, nil } func IsDirectory(path string) (bool, error) { diff --git a/common/engine/manager.go b/common/engine/manager.go index b283115..3a7c9d8 100644 --- a/common/engine/manager.go +++ b/common/engine/manager.go @@ -149,8 +149,12 @@ func (m *Manager) AddFileToRepo(relFilePath string) error { //DELAYED: this feature affects only large files and user experience. It can wait. relFilePath = strings.TrimSpace(relFilePath) //purging any odd spaces TODO: Make sure not needed var tmpFile database.File - filename := filepath.Base(relFilePath) - var hash []byte + tmpFile.Path = relFilePath + filename := filepath.Base(tmpFile.Path) + alreadyTracked := m.dB.CheckIfFileCurrentlyMonitored(tmpFile.Path) + if alreadyTracked { + return fmt.Errorf("file already found in tracked files, not adding: %s", relFilePath) + } //check that the file actually exists (currently done by client/server) // if filename, err = VerifySrcFile(relFilePath); err != nil { // //there was no source file or it was not recognisable as a file @@ -158,19 +162,12 @@ func (m *Manager) AddFileToRepo(relFilePath string) error { // } //generate a unique file name from the hash and the moment it was created //a sampled (and therefore) fast, hash of the file for 'uniqueness' - if hash, err = UniqueFileHash(relFilePath); err != nil { + + if err = tmpFile.CalculateHash(); err != nil { //creates the hash for the file return err } - m.Info().Msgf("Hash generated for file: %s hash: %s", relFilePath, hex.EncodeToString(hash)) - alreadyTracked := m.dB.CheckIfFileCurrentlyMonitored(relFilePath) - if alreadyTracked { - return fmt.Errorf("file already found in tracked files, not adding: %s", relFilePath) - } - tmpFile = database.File{} - - tmpFile.Hash = hash + m.Info().Msgf("Hash generated for file: %s hash: %s", tmpFile.Path, hex.EncodeToString(tmpFile.Hash)) tmpFile.Name = filename - tmpFile.Path = relFilePath tmpFile.CreatedAt = time.Now() tmpFile.Unique = hex.EncodeToString([]byte(filename)) + "_" + hex.EncodeToString((tmpFile.Hash)) + "_" + strconv.FormatInt(tmpFile.CreatedAt.Unix(), 10) + "_" + filename //tmpFile.BkpLocation = filepath.Join(m.SyncFolder, tmpFile.Unique) @@ -207,6 +204,7 @@ func (m *Manager) prepareDatabaseForFile(tmpFile database.File) (int, error) { // BeginCommit starts the commit process func (m *Manager) BeginCommit(branch string, commitMessage string) error { fmt.Println("Beginning Commit on Branch: ", branch) + trackedFiles, err := m.dB.RetrieveTrackedFiles() if err != nil { return err @@ -214,6 +212,15 @@ func (m *Manager) BeginCommit(branch string, commitMessage string) error { if len(trackedFiles) == 0 { return fmt.Errorf("no files show as tracked in repo, cannot commit, aborting...") } + commit, err := m.dB.FetchLastCommitOnBranch(branch) //Check for previous commits + if err != nil { + m.Info().Msgf("unable to fetch last commit on branch, assuming first commit on branch", err) + err := m.CreateInitialCommit(trackedFiles, branch, commitMessage) // Create the initial commit + if err != nil { + m.Err(err).Msgf("unable to create initial commit: %s", err) + return err + } + } var filesToDiff []database.File // Contains the list of files that have changed for _, trackedFile := range trackedFiles { fmt.Println("Working on file: ", trackedFile.Path) @@ -226,7 +233,6 @@ func (m *Manager) BeginCommit(branch string, commitMessage string) error { fmt.Printf("unable to stat tracked file: %s error: %s\n", currentFile.Name(), err) continue } - currentFileHash, err := UniqueFileHash(trackedFile.Path) if err != nil { fmt.Printf("unable to create hash for file: %s error: %s\n", currentFile.Name(), err) @@ -242,14 +248,10 @@ func (m *Manager) BeginCommit(branch string, commitMessage string) error { //diffChannel := make(chan database.DiffObject) //diffContext := context.Background() //m.WaitGroup.Add(2) - commit, err := m.dB.FetchLastCommitOnBranch(branch) - if err != nil { - m.Info().Msgf("unable to fetch last commit on branch, assuming first commit on branch", err) - err := m.CreateInitialCommit(filesToDiff, commitMessage) - if err != nil { - m.Err(err).Msgf("unable to create initial commit: %s", err) - return err - } + fmt.Println("Changed Files: ", filesToDiff) + if len(filesToDiff) == 0 { + m.Info().Msgf("No changed files found to commit on branch: %s", branch) + return fmt.Errorf("no changed files, cannot commit on branch: %s", branch) } fmt.Println("COMMIT: ", commit.CommitHash) return nil diff --git a/common/engine/watcher.go b/common/engine/watcher.go index f4c6e94..2a57881 100644 --- a/common/engine/watcher.go +++ b/common/engine/watcher.go @@ -67,7 +67,7 @@ func (fw *FileWatcher) BeginWatcherRoutine(ctx context.Context, wg *sync.WaitGro //this is currently slow as it does a db lookup on the path. //TODO: On load (or whenever a file is added to the watcher, the db information for files being watched, could be cached in memory. This would be much faster) fileInfo, err := onFileChanged(event.Path) //could return the 'Event' object here - syncFilePath := fileInfo.CurrentBase + syncFilePath := fileInfo.BaseFilePath //uniqueName := fileInfo.Unique // fileID := fileInfo.ID diff --git a/go.mod b/go.mod index 1ec69e1..5a3249c 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,8 @@ require ( github.com/golang/snappy v0.0.1 // indirect github.com/imdario/mergo v0.3.9 github.com/kalafut/imohash v1.0.0 + github.com/klauspost/compress v1.10.10 // indirect + github.com/klauspost/pgzip v1.2.4 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect github.com/mattn/go-colorable v0.1.6 // indirect diff --git a/go.sum b/go.sum index 1caa5d7..d301708 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,10 @@ github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/kalafut/imohash v1.0.0 h1:LgCJ+p/BwM2HKpOxFopkeddpzVCfm15EtXMroXD1SYE= github.com/kalafut/imohash v1.0.0/go.mod h1:c3RHT80ZAp5C/aYgQI92ZlrOymqkZnRDprU87kg75HI= +github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd/0B3I= +github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/pgzip v1.2.4 h1:TQ7CNpYKovDOmqzRHKxJh0BeaBI7UdQZYc6p7pMQh1A= +github.com/klauspost/pgzip v1.2.4/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=