aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-05-23 14:39:33 (EDT)
committerKevin Sawicki2011-05-23 14:39:33 (EDT)
commit16e810b2ec37c2db8bc0e39426be385024a8de8a (patch)
treee1c682ea4d6083ffdc47253026c4ffd964f4db3c
parentc25c60061d43b521a428301960120794b9fba4f2 (diff)
downloadjgit-16e810b2ec37c2db8bc0e39426be385024a8de8a.zip
jgit-16e810b2ec37c2db8bc0e39426be385024a8de8a.tar.gz
jgit-16e810b2ec37c2db8bc0e39426be385024a8de8a.tar.bz2
Add shortening of note ref names to NoteMaprefs/changes/04/3504/3
Change-Id: I224190bbb41c7cbea38388d0148ecc6dc68f3a14 Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java13
2 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java
index 94fdc69..84b10f3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java
@@ -522,6 +522,14 @@ public class NoteMapTest extends RepositoryTestCase {
assertEquals(2, count(it));
}
+ public void testShorteningNoteRefName() throws Exception {
+ String expectedShortName = "review";
+ String noteRefName = Constants.R_NOTES + expectedShortName;
+ assertEquals(expectedShortName, NoteMap.shortenRefName(noteRefName));
+ String nonNoteRefName = Constants.R_HEADS + expectedShortName;
+ assertEquals(nonNoteRefName, NoteMap.shortenRefName(expectedShortName));
+ }
+
private RevCommit commitNoteMap(NoteMap map) throws IOException {
tr.tick(600);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
index 0d4d6b9..3c43478 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
@@ -81,6 +81,19 @@ public class NoteMap implements Iterable<Note> {
}
/**
+ * Shorten the note ref name by trimming off the {@link Constants#R_NOTES}
+ * prefix if it exists.
+ *
+ * @param noteRefName
+ * @return a more user friendly note name
+ */
+ public static String shortenRefName(String noteRefName) {
+ if (noteRefName.startsWith(Constants.R_NOTES))
+ return noteRefName.substring(Constants.R_NOTES.length());
+ return noteRefName;
+ }
+
+ /**
* Load a collection of notes from a branch.
*
* @param reader