#16 -- Remove repo after indexing
This commit is contained in:
parent
c89a27d495
commit
014af08531
@ -1,5 +1,6 @@
|
||||
package ru.ulstu.extractor.service;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.jgit.api.CreateBranchCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.ListBranchCommand;
|
||||
@ -42,14 +43,14 @@ public class GitRepositoryService {
|
||||
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
||||
git = new Git(localRepo);
|
||||
git.pull().call();
|
||||
localRepo.close();
|
||||
} else {
|
||||
git = Git.cloneRepository()
|
||||
.setURI(url)
|
||||
.setDirectory(getProjectDirectoryFile(url))
|
||||
.call();
|
||||
}
|
||||
Iterable<RevCommit> commits = git.log().call();
|
||||
//commits.forEach(c -> System.out.println(c.getFullMessage()));
|
||||
git.close();
|
||||
}
|
||||
|
||||
private String getProjectDirectory(String url) {
|
||||
@ -101,6 +102,8 @@ public class GitRepositoryService {
|
||||
list.add(commit);
|
||||
prevCommit = revCommit;
|
||||
}
|
||||
git.close();
|
||||
localRepo.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -207,14 +210,17 @@ public class GitRepositoryService {
|
||||
cloneOrUpdateRepo(url);
|
||||
Repository localRepo = new FileRepository(getProjectGitDirectory(url));
|
||||
Git git = new Git(localRepo);
|
||||
return git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE)
|
||||
List<Branch> branches = git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE)
|
||||
.call()
|
||||
.stream()
|
||||
.map(r -> new Branch(r.getName().replace(BRANCH_PREFIX, "")))
|
||||
.collect(Collectors.toList());
|
||||
git.close();
|
||||
localRepo.close();
|
||||
return branches;
|
||||
}
|
||||
|
||||
public void remove(String repositoryUrl) throws IOException {
|
||||
//FileUtils.deleteDirectory(getProjectDirectoryFile(repositoryUrl));
|
||||
FileUtils.deleteDirectory(getProjectDirectoryFile(repositoryUrl));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user