From f08c1ca55e1ffaef81f3d6514aa4bffa5d716c5b Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sun, 05 Jun 2011 15:21:12 -0400
Subject: [PATCH] Added git-notes to docs. Fixed parent path mode.
---
src/com/gitblit/utils/JGitUtils.java | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 2590a30..6e02b9c 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -211,7 +211,7 @@
}
public static Map<ObjectId, List<RefModel>> getAllRefs(Repository r) {
- List<RefModel> list = getRefs(r, org.eclipse.jgit.lib.RefDatabase.ALL, -1);
+ List<RefModel> list = getRefs(r, org.eclipse.jgit.lib.RefDatabase.ALL, true, -1);
Map<ObjectId, List<RefModel>> refs = new HashMap<ObjectId, List<RefModel>>();
for (RefModel ref : list) {
ObjectId objectid = ref.getReferencedObjectId();
@@ -613,23 +613,23 @@
return list;
}
- public static List<RefModel> getTags(Repository r, int maxCount) {
- return getRefs(r, Constants.R_TAGS, maxCount);
+ public static List<RefModel> getTags(Repository r, boolean fullName, int maxCount) {
+ return getRefs(r, Constants.R_TAGS, fullName, maxCount);
}
- public static List<RefModel> getLocalBranches(Repository r, int maxCount) {
- return getRefs(r, Constants.R_HEADS, maxCount);
+ public static List<RefModel> getLocalBranches(Repository r, boolean fullName, int maxCount) {
+ return getRefs(r, Constants.R_HEADS, fullName, maxCount);
}
- public static List<RefModel> getRemoteBranches(Repository r, int maxCount) {
- return getRefs(r, Constants.R_REMOTES, maxCount);
+ public static List<RefModel> getRemoteBranches(Repository r, boolean fullName, int maxCount) {
+ return getRefs(r, Constants.R_REMOTES, fullName, maxCount);
}
- public static List<RefModel> getNotesRefs(Repository r, int maxCount) {
- return getRefs(r, Constants.R_NOTES, maxCount);
+ public static List<RefModel> getNotesRefs(Repository r, boolean fullName, int maxCount) {
+ return getRefs(r, Constants.R_NOTES, fullName, maxCount);
}
- private static List<RefModel> getRefs(Repository r, String refs, int maxCount) {
+ private static List<RefModel> getRefs(Repository r, String refs, boolean fullName, int maxCount) {
List<RefModel> list = new ArrayList<RefModel>();
try {
Map<String, Ref> map = r.getRefDatabase().getRefs(refs);
@@ -637,7 +637,11 @@
for (Entry<String, Ref> entry : map.entrySet()) {
Ref ref = entry.getValue();
RevObject object = rw.parseAny(ref.getObjectId());
- list.add(new RefModel(entry.getKey(), ref, object));
+ String name = entry.getKey();
+ if (fullName && !StringUtils.isEmpty(refs)) {
+ name = refs + name;
+ }
+ list.add(new RefModel(name, ref, object));
}
rw.dispose();
Collections.sort(list);
@@ -653,7 +657,7 @@
public static List<GitNote> getNotesOnCommit(Repository repository, RevCommit commit) {
List<GitNote> list = new ArrayList<GitNote>();
- List<RefModel> notesRefs = getNotesRefs(repository, -1);
+ List<RefModel> notesRefs = getNotesRefs(repository, true, -1);
for (RefModel notesRef : notesRefs) {
RevTree notesTree = JGitUtils.getCommit(repository, notesRef.getName()).getTree();
StringBuilder sb = new StringBuilder(commit.getName());
--
Gitblit v1.9.1