Skip to content
Snippets Groups Projects
Commit 2a15e823 authored by Jack MacLauchlan CS2015's avatar Jack MacLauchlan CS2015
Browse files

tree updated properly i think?

parent 873c1b48
No related branches found
No related tags found
1 merge request!2Commit tree
......@@ -24,7 +24,7 @@ public class CommandComment implements Command {
issue.addComment(new Comment(issueRepository.getUserAndEmail(), comment));
try {
String commitMessage = "Commented on issue " + issue.getTitle();
issueRepository.writeIssue(issue, commitMessage);
issueRepository.updateIssue(issue, commitMessage);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -42,7 +42,7 @@ public class CommandTag implements Command {
}
if (commitMessage != null) {
try {
repo.writeIssue(issue, commitMessage);
repo.updateIssue(issue, commitMessage);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -54,7 +54,7 @@ public class CommandUpdate implements Command {
}
if (commitMessage != null) {
try {
repo.writeIssue(issue, commitMessage);
repo.updateIssue(issue, commitMessage);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -35,7 +35,6 @@ public class IssueReader {
String content = getContent(blob);
String hash = split(treeWalk.getPathString(), 0);
System.out.println(treeWalk.getPathString());
if (issues.isEmpty() || getIssue(hash) == null) {
Issue issue = new Issue();
......
......@@ -106,6 +106,20 @@ public class IssueRepo {
// index.unlock();
}
public void updateIssue(Issue issue, String commitMessage) throws IOException {
RevCommit currentCommit = getCurrentCommit();
IssueTreeBuilder issueWriter = new IssueTreeBuilder(repository);
ObjectId issueTree = issueWriter.buildIssueTree(issue);
TreeFormatter repoTreeFormatter = removeFromRepoTree(currentCommit.getTree(), issue.getOriginalHash());
repoTreeFormatter.append(issue.getOriginalHash(), FileMode.TREE, issueTree);
ObjectId repoTree = oi.insert(Constants.OBJ_TREE, repoTreeFormatter.toByteArray());
commit(commitMessage, repoTree, currentCommit);
}
public void deleteIssue(String hash) throws IOException {
DirCache index = repository.lockDirCache();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment