diff options
author | James Moger <james.moger@gitblit.com> | 2011-04-11 08:18:22 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-04-11 08:18:22 -0400 |
commit | ef5c58d12ff33e4f2b83b6dcd53bdb6c96a6150d (patch) | |
tree | 5f936789acb589032a7b159408f577a19ec700b8 /src/com/gitblit/utils | |
parent | 698678268f53067c239a11e928dfd16761a2f9f7 (diff) | |
download | gitblit-ef5c58d12ff33e4f2b83b6dcd53bdb6c96a6150d.tar.gz gitblit-ef5c58d12ff33e4f2b83b6dcd53bdb6c96a6150d.zip |
Page log.
Diffstat (limited to 'src/com/gitblit/utils')
-rw-r--r-- | src/com/gitblit/utils/JGitUtils.java | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 1b418b08..abecac41 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Map;
import java.util.Set;
-import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.diff.RawTextComparator;
@@ -286,7 +285,7 @@ public class JGitUtils { public static String getCommitDiff(Repository r, RevCommit commit, boolean outputHtml) {
return getCommitDiff(r, commit, null, outputHtml);
}
-
+
public static String getCommitDiff(Repository r, RevCommit commit, String path, boolean outputHtml) {
try {
final RevWalk rw = new RevWalk(r);
@@ -380,16 +379,39 @@ public class JGitUtils { }
public static List<RevCommit> getRevLog(Repository r, int maxCount) {
+ return getRevLog(r, Constants.HEAD, 0, maxCount);
+ }
+
+ public static List<RevCommit> getRevLog(Repository r, String objectId, int offset, int maxCount) {
List<RevCommit> list = new ArrayList<RevCommit>();
try {
- Git git = new Git(r);
- Iterable<RevCommit> revlog = git.log().call();
- for (RevCommit rev : revlog) {
- list.add(rev);
- if (maxCount > 0 && list.size() == maxCount) {
- break;
+ if (objectId == null || objectId.trim().length() == 0) {
+ objectId = Constants.HEAD;
+ }
+ RevWalk walk = new RevWalk(r);
+ ObjectId object = r.resolve(objectId);
+ walk.markStart(walk.parseCommit(object));
+ Iterable<RevCommit> revlog = walk;
+ if (offset > 0) {
+ int count = 0;
+ for (RevCommit rev : revlog) {
+ count++;
+ if (count > offset) {
+ list.add(rev);
+ if (maxCount > 0 && list.size() == maxCount) {
+ break;
+ }
+ }
+ }
+ } else {
+ for (RevCommit rev : revlog) {
+ list.add(rev);
+ if (maxCount > 0 && list.size() == maxCount) {
+ break;
+ }
}
}
+ walk.dispose();
} catch (Throwable t) {
LOGGER.error("Failed to determine last change", t);
}
@@ -504,8 +526,10 @@ public class JGitUtils { final Map<String, Metric> map = new HashMap<String, Metric>();
try {
DateFormat df = new SimpleDateFormat("yyyy-MM");
- Git git = new Git(r);
- Iterable<RevCommit> revlog = git.log().call();
+ RevWalk walk = new RevWalk(r);
+ ObjectId object = r.resolve(Constants.HEAD);
+ walk.markStart(walk.parseCommit(object));
+ Iterable<RevCommit> revlog = walk;
for (RevCommit rev : revlog) {
Date d = getCommitDate(rev);
String p = df.format(d);
|