From dbc0831e24e391a78e490b892e958a05d7e95116 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 19 May 2011 17:18:29 -0400
Subject: [PATCH] Documentation tweak.
---
src/com/gitblit/tests/JGitUtilsTest.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/src/com/gitblit/tests/JGitUtilsTest.java b/src/com/gitblit/tests/JGitUtilsTest.java
index c04ceef..196058c 100644
--- a/src/com/gitblit/tests/JGitUtilsTest.java
+++ b/src/com/gitblit/tests/JGitUtilsTest.java
@@ -15,49 +15,60 @@
import org.eclipse.jgit.storage.file.FileRepository;
import com.gitblit.utils.JGitUtils;
-
+import com.gitblit.utils.JGitUtils.DiffOutputType;
+import com.gitblit.wicket.models.PathModel.PathChangeModel;
+import com.gitblit.wicket.models.RefModel;
+import com.gitblit.wicket.models.TicketModel;
public class JGitUtilsTest extends TestCase {
-
+
private File repositoriesFolder = new File("c:/projects/git");
private boolean exportAll = true;
private boolean readNested = true;
-
+
private List<String> getRepositories() {
return JGitUtils.getRepositoryList(repositoriesFolder, exportAll, readNested);
}
-
+
private Repository getRepository() throws Exception {
return new FileRepository(new File(repositoriesFolder, getRepositories().get(0)) + "/" + Constants.DOT_GIT);
}
-
+
public void testFindRepositories() {
List<String> list = getRepositories();
assertTrue("No repositories found in " + repositoriesFolder, list.size() > 0);
}
-
- public void testOpenRepository() throws Exception {
+
+ public void testOpenRepository() throws Exception {
Repository r = getRepository();
r.close();
assertTrue("Could not find repository!", r != null);
}
-
- public void testLastChangeRepository() throws Exception {
+
+ public void testLastChangeRepository() throws Exception {
Repository r = getRepository();
Date date = JGitUtils.getLastChange(r);
r.close();
assertTrue("Could not get last repository change date!", date != null);
}
+ public void testFirstCommit() throws Exception {
+ Repository r = getRepository();
+ RevCommit commit = JGitUtils.getFirstCommit(r, null);
+ r.close();
+ assertTrue("Could not get first commit!", commit != null);
+ System.out.println(commit.getName() + " " + commit.getShortMessage());
+ }
+
public void testRetrieveRevObject() throws Exception {
Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD);
RevTree tree = commit.getTree();
- RevObject object = JGitUtils.getRevObject(r, tree, "AUTHORS");
+ RevObject object = JGitUtils.getRevObject(r, tree, "AUTHORS");
r.close();
assertTrue("Object is null!", object != null);
}
-
+
public void testRetrieveStringContent() throws Exception {
Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD);
@@ -68,4 +79,29 @@
assertTrue("Content is null!", content != null);
}
+ public void testTicGit() throws Exception {
+ Repository r = new FileRepository(new File(repositoriesFolder, "ticgit") + "/" + Constants.DOT_GIT);
+ RefModel ticgit = JGitUtils.getTicketsBranch(r);
+ assertTrue("Ticgit branch does not exist!", ticgit != null);
+ List<TicketModel> tickets = JGitUtils.getTickets(r);
+ assertTrue("No tickets found!", tickets.size() > 0);
+ r.close();
+ }
+
+ public void testFilesInCommit() throws Exception {
+ Repository r = getRepository();
+ RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD);
+ List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);
+ r.close();
+ assertTrue("No changed paths found!", paths.size() > 0);
+ }
+
+ public void testCommitDiff() throws Exception {
+ Repository r = getRepository();
+ RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD);
+ String diff = JGitUtils.getCommitDiff(r, commit, DiffOutputType.PLAIN);
+ r.close();
+ System.out.println(diff);
+ }
+
}
--
Gitblit v1.9.1