Skip to content

Java06. ДЗ 02, Murycheva Natalia#9

Open
natalymr wants to merge 9 commits intomasterfrom
sem2-hw2
Open

Java06. ДЗ 02, Murycheva Natalia#9
natalymr wants to merge 9 commits intomasterfrom
sem2-hw2

Conversation

@natalymr
Copy link
Owner

  • 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

natalymr and others added 5 commits September 17, 2018 23:14
 - 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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем во многих местах обертки вместо примитивов?


if (!root.isPresent())
return Optional.empty();
// use BFS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

т.к. нет веток и структура линейная, то ни бфс, ни дфс не нужны

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Но если сделать два коммита,
потом сделать checkout на первый коммит
и сделать потом третий коммит.

В моем случае, если вызвать команду mygit log, будут видны все три коммита. Именно поэтому и сделан бфс

index = new Index(gitPath);

// create .git/HEAD.txt
head = new Head(gitPath);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

второе:
до сих пор не умеет загружаться с диска без инита
нет CLI
нет reset

второе тоже не зачтено, но его можно доделывать (вкл унаследованные замечания), а первое нельзя


/* file is removed from restoredDirContains if this file was handled */
if (restoredDirContains.contains(new File(path))) {
restoredDirContains.remove(new File(path));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вызывать remove можно без проверки на присутствие

if (isInObjectsDir(hash)) {
String blobFileContent = FileUtils.readFileToString(new File(getFullPathByName(hash)),
"UTF-8");
blobFileContent = blobFileContent.substring(5, blobFileContent.length());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

второй параметр не нужен, см перегрузку substring

String fullPathToBlobFile = getFullPathByName(hashBlobFileInString);
String blobFileContent = FileUtils.readFileToString(new File(fullPathToBlobFile), "UTF-8");

blobFileContent = blobFileContent.substring(5, blobFileContent.length());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и здесь второй параметр не нужен
магические константы лучше либо комметировать, либо писать как есть "BLOB\n".length()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants