|
|
|
@ -150,6 +150,48 @@ public class BlameCommandTest extends RepositoryTestCase {
|
|
|
|
|
assertEquals("file1.txt", lines.getSourcePath(2)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testTwoRenames() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
|
|
|
|
|
// Commit 1: Add file.txt
|
|
|
|
|
String[] content1 = new String[] { "a" }; |
|
|
|
|
writeTrashFile("file.txt", join(content1)); |
|
|
|
|
git.add().addFilepattern("file.txt").call(); |
|
|
|
|
RevCommit commit1 = git.commit().setMessage("create file").call(); |
|
|
|
|
|
|
|
|
|
// Commit 2: Rename to file1.txt
|
|
|
|
|
writeTrashFile("file1.txt", join(content1)); |
|
|
|
|
git.add().addFilepattern("file1.txt").call(); |
|
|
|
|
git.rm().addFilepattern("file.txt").call(); |
|
|
|
|
git.commit().setMessage("moving file").call(); |
|
|
|
|
|
|
|
|
|
// Commit 3: Edit file1.txt
|
|
|
|
|
String[] content2 = new String[] { "a", "b" }; |
|
|
|
|
writeTrashFile("file1.txt", join(content2)); |
|
|
|
|
git.add().addFilepattern("file1.txt").call(); |
|
|
|
|
RevCommit commit3 = git.commit().setMessage("editing file").call(); |
|
|
|
|
|
|
|
|
|
// Commit 4: Rename to file2.txt
|
|
|
|
|
writeTrashFile("file2.txt", join(content2)); |
|
|
|
|
git.add().addFilepattern("file2.txt").call(); |
|
|
|
|
git.rm().addFilepattern("file1.txt").call(); |
|
|
|
|
git.commit().setMessage("moving file again").call(); |
|
|
|
|
|
|
|
|
|
BlameCommand command = new BlameCommand(db); |
|
|
|
|
command.setFollowFileRenames(true); |
|
|
|
|
command.setFilePath("file2.txt"); |
|
|
|
|
BlameResult lines = command.call(); |
|
|
|
|
|
|
|
|
|
assertEquals(commit1, lines.getSourceCommit(0)); |
|
|
|
|
assertEquals(0, lines.getSourceLine(0)); |
|
|
|
|
assertEquals("file.txt", lines.getSourcePath(0)); |
|
|
|
|
|
|
|
|
|
assertEquals(commit3, lines.getSourceCommit(1)); |
|
|
|
|
assertEquals(1, lines.getSourceLine(1)); |
|
|
|
|
assertEquals("file1.txt", lines.getSourcePath(1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testDeleteTrailingLines() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|