Change-Id: I224190bbb41c7cbea38388d0148ecc6dc68f3a14 Signed-off-by: Kevin Sawicki <kevin@github.com>tags/v1.0.0.201106011211-rc3
@@ -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); | |||
@@ -80,6 +80,19 @@ public class NoteMap implements Iterable<Note> { | |||
return r; | |||
} | |||
/** | |||
* 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. | |||
* |