The Unified and Autonomous Development Platform
do not throw exception when commit deletion of a non-existent file.
robin shinef7718a22a666
diff --git a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.javaindex e005bd5c93..dec3de9ba5 100644--- a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java+++ b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java@@ -203,9 +203,7 @@ public class GitUtils {appended = true;}}- if (!found) {- if (content == null)- throw new ObjectNotFoundException("Unable to find blob: " + path);+ if (!found && content != null) {List<String> splitted = Splitter.on('/').splitToList(path);ObjectId childId = null;diff --git a/commons.git/src/test/java/com/pmease/commons/git/GitUtilsTest.java b/commons.git/src/test/java/com/pmease/commons/git/GitUtilsTest.javaindex 372128c10f..852f339850 100644--- a/commons.git/src/test/java/com/pmease/commons/git/GitUtilsTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/GitUtilsTest.java@@ -84,13 +84,15 @@ public class GitUtilsTest extends AbstractGitTest {ObjectId oldCommitId = repo.resolve(refName);PersonIdent person = new PersonIdent(repo);- try {- GitUtils.commitFile(repo, "refs/heads/master",- oldCommitId, oldCommitId, person,- "test delete", "/server/src/com/example/a//c.java", null);- assertTrue("An ObjectNotFoundException should be thrown", false);- } catch(ObjectNotFoundException e) {-+ ObjectId newCommitId = GitUtils.commitFile(repo, refName, oldCommitId, oldCommitId,+ person, "test delete", "/server/src/com/example/c//c.java", null);++ try (RevWalk revWalk = new RevWalk(repo)) {+ RevTree revTree = revWalk.parseCommit(newCommitId).getTree();+ assertNotNull(TreeWalk.forPath(repo, "server/src/com/example/a/a.java", revTree));+ assertNotNull(TreeWalk.forPath(repo, "server/src/com/example/b/b.java", revTree));+ assertNotNull(TreeWalk.forPath(repo, "client/a.java", revTree));+ assertNotNull(TreeWalk.forPath(repo, "client/b.java", revTree));}}}