vishalvivekm/vcs

broken logic for monitoring file changes

Closed this issue · 0 comments

Current logic for checking file changes:

./main commit "made minor changes"

Create individual hash of all staged files, and then hash the individual hashes to generate a new commit ID.
create directory for each successful commit inside vcs/commits/${commit ID} using os.Mkdir
if it throws errand if os.IsExist(err) is true, Print No files were changed and return.

issues

$ cat a.txt
This is a.txt
1>commit

$ cat a.txt
this is a. txtt
2> commit

$ cat a.txt
this is a.txt
3>commit

3 commit will say "no files were changed" and exit, when it's clear that a.txt was modified since last commit.

potential solution

?
compare the current commit ID with the previous commit id, if they match: no changes