use of org.eclipse.jgit.lib.Repository in project gitblit by gitblit.
the class LuceneExecutorTest method testMultiSearch.
@Test
public void testMultiSearch() throws Exception {
List<String> list = new ArrayList<String>();
Repository repository = GitBlitSuite.getHelloworldRepository();
list.add(newRepositoryModel(repository).name);
repository.close();
repository = GitBlitSuite.getJGitRepository();
list.add(newRepositoryModel(repository).name);
repository.close();
List<SearchResult> results = lucene.search("test", 1, 10, list);
assertEquals(10, results.size());
}
use of org.eclipse.jgit.lib.Repository in project gitblit by gitblit.
the class LuceneExecutorTest method testIndex.
@Test
public void testIndex() {
// reindex helloworld
Repository repository = GitBlitSuite.getHelloworldRepository();
RepositoryModel model = newRepositoryModel(repository);
lucene.reindex(model, repository);
repository.close();
SearchResult result = lucene.search("type:blob AND path:bit.bit", 1, 1, model.name).get(0);
assertEquals("Mike Donaghy", result.author);
result = lucene.search("type:blob AND path:clipper.prg", 1, 1, model.name).get(0);
assertEquals("tinogomes", result.author);
// reindex JGit
repository = GitBlitSuite.getJGitRepository();
model = newRepositoryModel(repository);
lucene.reindex(model, repository);
repository.close();
}
use of org.eclipse.jgit.lib.Repository in project gitblit by gitblit.
the class JGitUtilsTest method testCommitNotes.
@Test
public void testCommitNotes() throws Exception {
Repository repository = GitBlitSuite.getJGitRepository();
RevCommit commit = JGitUtils.getCommit(repository, "690c268c793bfc218982130fbfc25870f292295e");
List<GitNote> list = JGitUtils.getNotesOnCommit(repository, commit);
repository.close();
assertTrue(list.size() > 0);
assertEquals("183474d554e6f68478a02d9d7888b67a9338cdff", list.get(0).notesRef.getReferencedObjectId().getName());
}
use of org.eclipse.jgit.lib.Repository in project gitblit by gitblit.
the class JGitUtilsTest method testCreateRepositoryShared.
@Test
public void testCreateRepositoryShared() throws Exception {
String[] repositories = { "NewSharedTestRepository.git" };
for (String repositoryName : repositories) {
Repository repository = JGitUtils.createRepository(GitBlitSuite.REPOSITORIES, repositoryName, "group");
File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName), FS.DETECTED);
assertNotNull(repository);
assertFalse(JGitUtils.hasCommits(repository));
assertNull(JGitUtils.getFirstCommit(repository, null));
assertEquals("1", repository.getConfig().getString("core", null, "sharedRepository"));
assertTrue(folder.exists());
if (!JnaUtils.isWindows()) {
int mode = JnaUtils.getFilemode(folder);
assertEquals(JnaUtils.S_ISGID, mode & JnaUtils.S_ISGID);
assertEquals(JnaUtils.S_IRWXG, mode & JnaUtils.S_IRWXG);
mode = JnaUtils.getFilemode(folder.getAbsolutePath() + "/HEAD");
assertEquals(JnaUtils.S_IRGRP | JnaUtils.S_IWGRP, mode & JnaUtils.S_IRWXG);
mode = JnaUtils.getFilemode(folder.getAbsolutePath() + "/config");
assertEquals(JnaUtils.S_IRGRP | JnaUtils.S_IWGRP, mode & JnaUtils.S_IRWXG);
}
repository.close();
RepositoryCache.close(repository);
FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE);
}
}
use of org.eclipse.jgit.lib.Repository in project gitblit by gitblit.
the class JGitUtilsTest method testBranches.
@Test
public void testBranches() throws Exception {
Repository repository = GitBlitSuite.getJGitRepository();
assertTrue(JGitUtils.getLocalBranches(repository, true, 0).size() == 0);
for (RefModel model : JGitUtils.getLocalBranches(repository, true, -1)) {
assertTrue(model.getName().startsWith(Constants.R_HEADS));
assertTrue(model.equals(model));
assertFalse(model.equals(""));
assertTrue(model.hashCode() == model.getReferencedObjectId().hashCode() + model.getName().hashCode());
assertTrue(model.getShortMessage().equals(model.getShortMessage()));
}
for (RefModel model : JGitUtils.getRemoteBranches(repository, true, -1)) {
assertTrue(model.getName().startsWith(Constants.R_REMOTES));
assertTrue(model.equals(model));
assertFalse(model.equals(""));
assertTrue(model.hashCode() == model.getReferencedObjectId().hashCode() + model.getName().hashCode());
assertTrue(model.getShortMessage().equals(model.getShortMessage()));
}
assertTrue(JGitUtils.getRemoteBranches(repository, true, 8).size() == 8);
repository.close();
}
Aggregations