Conversation
- git init - git add - git commit - git log
- git log - git log(from revision) - git checkout(file) - git checkout(revision) - git rm(file) - git status Add several supporting classes and moved methods in them
| */ | ||
| public void add(Path pathToFile) { | ||
| /* create blobFile for this file and get hash(blobFileContent) */ | ||
| Integer hash = objects.createNewBlobFile(pathToFile); |
There was a problem hiding this comment.
зачем во многих местах обертки вместо примитивов?
|
|
||
| if (!root.isPresent()) | ||
| return Optional.empty(); | ||
| // use BFS |
There was a problem hiding this comment.
т.к. нет веток и структура линейная, то ни бфс, ни дфс не нужны
There was a problem hiding this comment.
Но если сделать два коммита,
потом сделать checkout на первый коммит
и сделать потом третий коммит.
В моем случае, если вызвать команду mygit log, будут видны все три коммита. Именно поэтому и сделан бфс
| index = new Index(gitPath); | ||
|
|
||
| // create .git/HEAD.txt | ||
| head = new Head(gitPath); |
There was a problem hiding this comment.
второе:
до сих пор не умеет загружаться с диска без инита
нет CLI
нет reset
второе тоже не зачтено, но его можно доделывать (вкл унаследованные замечания), а первое нельзя
|
|
||
| /* file is removed from restoredDirContains if this file was handled */ | ||
| if (restoredDirContains.contains(new File(path))) { | ||
| restoredDirContains.remove(new File(path)); |
There was a problem hiding this comment.
вызывать remove можно без проверки на присутствие
| if (isInObjectsDir(hash)) { | ||
| String blobFileContent = FileUtils.readFileToString(new File(getFullPathByName(hash)), | ||
| "UTF-8"); | ||
| blobFileContent = blobFileContent.substring(5, blobFileContent.length()); |
There was a problem hiding this comment.
второй параметр не нужен, см перегрузку substring
| String fullPathToBlobFile = getFullPathByName(hashBlobFileInString); | ||
| String blobFileContent = FileUtils.readFileToString(new File(fullPathToBlobFile), "UTF-8"); | ||
|
|
||
| blobFileContent = blobFileContent.substring(5, blobFileContent.length()); |
There was a problem hiding this comment.
и здесь второй параметр не нужен
магические константы лучше либо комметировать, либо писать как есть "BLOB\n".length()
Add several supporting classes and moved methods in them