summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2016-05-04 15:48:36 -0700
committerJonathan Nieder <jrn@google.com>2016-05-04 15:48:36 -0700
commitbc9df9c63c748a6cf3aa2a3ff929484e4bdcc78d (patch)
tree7a628b0b5b8442747493a1f72895ac03bff4879a /org.eclipse.jgit.junit/src
parente89393ba3ee6b16b99a0afecd54521260ed6a66e (diff)
downloadjgit-bc9df9c63c748a6cf3aa2a3ff929484e4bdcc78d.tar.gz
jgit-bc9df9c63c748a6cf3aa2a3ff929484e4bdcc78d.zip
TestRepository: Add delete() method
Change-Id: Ib4841397ceab44bd38cf2f154314ac36ded73ae0
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index 1119e63824..d0045d6984 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -586,6 +586,31 @@ public class TestRepository<R extends Repository> {
}
}
+ /**
+ * Delete a reference.
+ *
+ * @param ref
+ * the name of the reference to delete. This is normalized
+ * in the same way as {@link #update(String, T)}.
+ * @throws Exception
+ * @since 4.4
+ */
+ public void delete(String ref) throws Exception {
+ ref = normalizeRef(ref);
+ RefUpdate u = db.updateRef(ref);
+ switch (u.delete()) {
+ case FAST_FORWARD:
+ case FORCED:
+ case NEW:
+ case NO_CHANGE:
+ updateServerInfo();
+ return;
+
+ default:
+ throw new IOException("Cannot delete " + ref + " " + u.getResult());
+ }
+ }
+
private static String normalizeRef(String ref) {
if (Constants.HEAD.equals(ref)) {
// nothing
@@ -959,6 +984,15 @@ public class TestRepository<R extends Repository> {
public RevCommit update(RevCommit to) throws Exception {
return TestRepository.this.update(ref, to);
}
+
+ /**
+ * Delete this branch.
+ * @throws Exception
+ * @since 4.4
+ */
+ public void delete() throws Exception {
+ TestRepository.this.delete(ref);
+ }
}
/** Helper to generate a commit. */