Lines 56-64
Link Here
|
56 |
import org.eclipse.jgit.lib.*; |
56 |
import org.eclipse.jgit.lib.*; |
57 |
import org.eclipse.jgit.revwalk.RevCommit; |
57 |
import org.eclipse.jgit.revwalk.RevCommit; |
58 |
import org.eclipse.jgit.treewalk.TreeWalk; |
58 |
import org.eclipse.jgit.treewalk.TreeWalk; |
59 |
import org.eclipse.jgit.treewalk.WorkingTreeOptions; |
|
|
60 |
import org.eclipse.jgit.treewalk.filter.PathFilter; |
59 |
import org.eclipse.jgit.treewalk.filter.PathFilter; |
61 |
import org.eclipse.jgit.util.io.AutoCRLFOutputStream; |
|
|
62 |
import org.netbeans.libs.git.GitClient; |
60 |
import org.netbeans.libs.git.GitClient; |
63 |
import org.netbeans.libs.git.GitException; |
61 |
import org.netbeans.libs.git.GitException; |
64 |
import org.netbeans.libs.git.GitStatus; |
62 |
import org.netbeans.libs.git.GitStatus; |
Lines 620-623
Link Here
|
620 |
assertEquals(e1.getObjectId(), walk.getObjectId(0)); |
618 |
assertEquals(e1.getObjectId(), walk.getObjectId(0)); |
621 |
} |
619 |
} |
622 |
} |
620 |
} |
|
|
621 |
|
622 |
public void testAmendCommit () throws Exception { |
623 |
repository.getConfig().setString("user", null, "name", "John"); |
624 |
repository.getConfig().setString("user", null, "email", "john@git.com"); |
625 |
repository.getConfig().save(); |
626 |
|
627 |
File dir = new File(workDir, "testdir"); |
628 |
File newOne = new File(dir, "test.txt"); |
629 |
File another = new File(dir, "test2.txt"); |
630 |
dir.mkdirs(); |
631 |
write(newOne, "content1"); |
632 |
write(another, "content2"); |
633 |
|
634 |
GitClient client = getClient(workDir); |
635 |
client.add(new File[] { newOne, another }, NULL_PROGRESS_MONITOR); |
636 |
GitRevisionInfo info = client.commit(new File[] { newOne, another }, "initial commit", null, null, NULL_PROGRESS_MONITOR); |
637 |
Map<File, GitStatus> statuses = client.getStatus(new File[] { newOne, another }, NULL_PROGRESS_MONITOR); |
638 |
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false); |
639 |
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false); |
640 |
|
641 |
write(newOne, "modification1"); |
642 |
write(another, "modification2"); |
643 |
|
644 |
client.add(new File[] { newOne, another }, NULL_PROGRESS_MONITOR); |
645 |
GitRevisionInfo lastCommit = client.commit(new File[] { newOne }, "second commit", null, null, false, NULL_PROGRESS_MONITOR); |
646 |
statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR); |
647 |
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false); |
648 |
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false); |
649 |
Map<File, GitFileInfo> modifiedFiles = lastCommit.getModifiedFiles(); |
650 |
assertTrue(modifiedFiles.get(newOne).getStatus().equals(Status.MODIFIED)); |
651 |
assertNull(modifiedFiles.get(another)); |
652 |
|
653 |
assertEquals(1, lastCommit.getParents().length); |
654 |
assertEquals(info.getRevision(), lastCommit.getParents()[0]); |
655 |
assertEquals(lastCommit.getRevision(), client.getBranches(false, NULL_PROGRESS_MONITOR).get("master").getId()); |
656 |
|
657 |
lastCommit = client.commit(new File[] { newOne, another }, "second commit, modified message", null, null, true, NULL_PROGRESS_MONITOR); |
658 |
statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR); |
659 |
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false); |
660 |
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false); |
661 |
modifiedFiles = lastCommit.getModifiedFiles(); |
662 |
assertTrue(modifiedFiles.get(newOne).getStatus().equals(Status.MODIFIED)); |
663 |
assertTrue(modifiedFiles.get(another).getStatus().equals(Status.MODIFIED)); |
664 |
|
665 |
assertEquals(1, lastCommit.getParents().length); |
666 |
assertEquals(info.getRevision(), lastCommit.getParents()[0]); |
667 |
assertEquals(lastCommit.getRevision(), client.getBranches(false, NULL_PROGRESS_MONITOR).get("master").getId()); |
668 |
} |
623 |
} |
669 |
} |