diff --git a/src/main/java/net/kemitix/gitdb/GitDBBranch.java b/src/main/java/net/kemitix/gitdb/GitDBBranch.java index 38e3d79..5f890f7 100644 --- a/src/main/java/net/kemitix/gitdb/GitDBBranch.java +++ b/src/main/java/net/kemitix/gitdb/GitDBBranch.java @@ -66,7 +66,7 @@ public class GitDBBranch { /** * Lookup a value for the key. * - * @param key the key to lookup + * @param key the key to lookup * @return an Optional containing the value, if it exists, or empty if not * @throws IOException if there was an error reading the value */ @@ -91,6 +91,16 @@ public class GitDBBranch { return updateBranch(commitId); } + /** + * Removes a key and its value from the store. + * + * @param key the key to remove + * @return an updated branch without the key, or the original if the key was not found + */ + public GitDBBranch remove(final String key) { + return this; + } + private ObjectId insertBlob(final byte[] blob) throws IOException { return gitDBRepo.insertBlob(blob); } @@ -114,5 +124,4 @@ public class GitDBBranch { final Ref updatedRef = gitDBRepo.writeHead(branchRef.getName(), commitId); return GitDBBranch.withRef(updatedRef, gitDBRepo, userName, userEmailAddress); } - } diff --git a/src/test/java/net/kemitix/gitdb/GitDBTest.java b/src/test/java/net/kemitix/gitdb/GitDBTest.java index 6de829c..ba569d4 100644 --- a/src/test/java/net/kemitix/gitdb/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/GitDBTest.java @@ -236,6 +236,16 @@ class GitDBTest implements WithAssertions { } // When removing a key that does not exist then the GitDbBranch is returned + @Test + void removeKey_whenNotExist_thenReturnOriginal() throws IOException { + //given + final GitDBBranch gitDBBranch = gitDBBranch(); + //when + final GitDBBranch result = gitDBBranch.remove("unknown"); + //then + assertThat(result).isSameAs(gitDBBranch); + } + // When removing a key that does exist then a GitDbBranch is returned // When removing a key that does exist then original GitDbBranch can still find it // When removing a key that does exist then the updated GitDbBranch can't find it