ApplyCommand: fix ApplyResult#updatedFiles
On executing a copy, mark the destination as updated. On executing a rename, mark both source and destination as updated. Change-Id: Ied5b9b0e5a14eac59a06cdd0961e25e143f50ff0
This commit is contained in:
parent
0887111ba5
commit
25aceffdc5
|
@ -525,9 +525,9 @@ public void testNonASCIIDel() throws Exception {
|
||||||
@Test
|
@Test
|
||||||
public void testRenameNoHunks() throws Exception {
|
public void testRenameNoHunks() throws Exception {
|
||||||
ApplyResult result = init("RenameNoHunks", true, true);
|
ApplyResult result = init("RenameNoHunks", true, true);
|
||||||
assertEquals(1, result.getUpdatedFiles().size());
|
assertEquals(2, result.getUpdatedFiles().size());
|
||||||
assertEquals(new File(db.getWorkTree(), "RenameNoHunks"), result.getUpdatedFiles()
|
assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "RenameNoHunks")));
|
||||||
.get(0));
|
assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "nested/subdir/Renamed")));
|
||||||
checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
|
checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
|
||||||
b.getString(0, b.size(), false));
|
b.getString(0, b.size(), false));
|
||||||
}
|
}
|
||||||
|
@ -535,9 +535,9 @@ public void testRenameNoHunks() throws Exception {
|
||||||
@Test
|
@Test
|
||||||
public void testRenameWithHunks() throws Exception {
|
public void testRenameWithHunks() throws Exception {
|
||||||
ApplyResult result = init("RenameWithHunks", true, true);
|
ApplyResult result = init("RenameWithHunks", true, true);
|
||||||
assertEquals(1, result.getUpdatedFiles().size());
|
assertEquals(2, result.getUpdatedFiles().size());
|
||||||
assertEquals(new File(db.getWorkTree(), "RenameWithHunks"), result.getUpdatedFiles()
|
assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "RenameWithHunks")));
|
||||||
.get(0));
|
assertTrue(result.getUpdatedFiles().contains(new File(db.getWorkTree(), "nested/subdir/Renamed")));
|
||||||
checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
|
checkFile(new File(db.getWorkTree(), "nested/subdir/Renamed"),
|
||||||
b.getString(0, b.size(), false));
|
b.getString(0, b.size(), false));
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ public void testRenameWithHunks() throws Exception {
|
||||||
public void testCopyWithHunks() throws Exception {
|
public void testCopyWithHunks() throws Exception {
|
||||||
ApplyResult result = init("CopyWithHunks", true, true);
|
ApplyResult result = init("CopyWithHunks", true, true);
|
||||||
assertEquals(1, result.getUpdatedFiles().size());
|
assertEquals(1, result.getUpdatedFiles().size());
|
||||||
assertEquals(new File(db.getWorkTree(), "CopyWithHunks"), result.getUpdatedFiles()
|
assertEquals(new File(db.getWorkTree(), "CopyResult"), result.getUpdatedFiles()
|
||||||
.get(0));
|
.get(0));
|
||||||
checkFile(new File(db.getWorkTree(), "CopyResult"),
|
checkFile(new File(db.getWorkTree(), "CopyResult"),
|
||||||
b.getString(0, b.size(), false));
|
b.getString(0, b.size(), false));
|
||||||
|
|
|
@ -157,13 +157,14 @@ public ApplyResult call() throws GitAPIException, PatchFormatException,
|
||||||
JGitText.get().renameFileFailed, f, dest), e);
|
JGitText.get().renameFileFailed, f, dest), e);
|
||||||
}
|
}
|
||||||
apply(repository, fh.getOldPath(), cache, dest, fh);
|
apply(repository, fh.getOldPath(), cache, dest, fh);
|
||||||
|
r.addUpdatedFile(dest);
|
||||||
break;
|
break;
|
||||||
case COPY:
|
case COPY:
|
||||||
f = getFile(fh.getOldPath(), false);
|
File src = getFile(fh.getOldPath(), false);
|
||||||
File target = getFile(fh.getNewPath(), false);
|
f = getFile(fh.getNewPath(), false);
|
||||||
FileUtils.mkdirs(target.getParentFile(), true);
|
FileUtils.mkdirs(f.getParentFile(), true);
|
||||||
Files.copy(f.toPath(), target.toPath());
|
Files.copy(src.toPath(), f.toPath());
|
||||||
apply(repository, fh.getOldPath(), cache, target, fh);
|
apply(repository, fh.getOldPath(), cache, f, fh);
|
||||||
}
|
}
|
||||||
r.addUpdatedFile(f);
|
r.addUpdatedFile(f);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue