Search in sources :

Example 31 with RefModel

use of com.gitblit.models.RefModel in project gitblit by gitblit.

the class LuceneExecutorTest method newRepositoryModel.

private RepositoryModel newRepositoryModel(Repository repository) {
    RepositoryModel model = new RepositoryModel();
    model.name = FileUtils.getRelativePath(GitBlitSuite.REPOSITORIES, repository.getDirectory());
    model.hasCommits = JGitUtils.hasCommits(repository);
    // index all local branches
    model.indexedBranches = new ArrayList<String>();
    for (RefModel ref : JGitUtils.getLocalBranches(repository, true, -1)) {
        model.indexedBranches.add(ref.getName());
    }
    return model;
}
Also used : RefModel(com.gitblit.models.RefModel) RepositoryModel(com.gitblit.models.RepositoryModel)

Example 32 with RefModel

use of com.gitblit.models.RefModel in project gitblit by gitblit.

the class JGitUtilsTest method testTags.

@Test
public void testTags() throws Exception {
    Repository repository = GitBlitSuite.getJGitRepository();
    assertTrue(JGitUtils.getTags(repository, true, 5).size() == 5);
    for (RefModel model : JGitUtils.getTags(repository, true, -1)) {
        if (model.getObjectId().getName().equals("d28091fb2977077471138fe97da1440e0e8ae0da")) {
            assertTrue("Not an annotated tag!", model.isAnnotatedTag());
        }
        assertTrue(model.getName().startsWith(Constants.R_TAGS));
        assertTrue(model.equals(model));
        assertFalse(model.equals(""));
        assertTrue(model.hashCode() == model.getReferencedObjectId().hashCode() + model.getName().hashCode());
    }
    repository.close();
    repository = GitBlitSuite.getGitectiveRepository();
    for (RefModel model : JGitUtils.getTags(repository, true, -1)) {
        if (model.getObjectId().getName().equals("035254295a9bba11f72b1f9d6791a6b957abee7b")) {
            assertFalse(model.isAnnotatedTag());
            assertTrue(model.getAuthorIdent().getEmailAddress().equals("kevinsawicki@gmail.com"));
            assertEquals("Add scm and issue tracker elements to pom.xml\n", model.getFullMessage());
        }
    }
    repository.close();
}
Also used : Repository(org.eclipse.jgit.lib.Repository) RefModel(com.gitblit.models.RefModel) Test(org.junit.Test)

Aggregations

RefModel (com.gitblit.models.RefModel)32 ArrayList (java.util.ArrayList)18 ObjectId (org.eclipse.jgit.lib.ObjectId)13 Repository (org.eclipse.jgit.lib.Repository)12 RevCommit (org.eclipse.jgit.revwalk.RevCommit)12 List (java.util.List)10 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 RepositoryModel (com.gitblit.models.RepositoryModel)6 RepositoryCommit (com.gitblit.models.RepositoryCommit)5 UserModel (com.gitblit.models.UserModel)5 Date (java.util.Date)5 TreeSet (java.util.TreeSet)4 RevWalk (org.eclipse.jgit.revwalk.RevWalk)4 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 IndexWriter (org.apache.lucene.index.IndexWriter)3 Ref (org.eclipse.jgit.lib.Ref)3 GitBlitException (com.gitblit.GitBlitException)2 PathChangeModel (com.gitblit.models.PathModel.PathChangeModel)2