use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class CompareActionsTest method testCompareWithIndex.
@Test
public void testCompareWithIndex() throws Exception {
String compareWithIndexActionLabel = util.getPluginLocalizedValue("CompareWithIndexAction_label");
clickCompareWith(compareWithIndexActionLabel);
// compare with index should not have any changes
assertTreeCompareNoChange();
// change test file -> should have one change
setTestFileContent("Hello there");
clickCompareWith(compareWithIndexActionLabel);
assertTreeCompareChanges(1);
// add to index -> no more changes
try (Git git = new Git(lookupRepository(repositoryFile))) {
git.add().addFilepattern(PROJ1 + "/" + FOLDER + "/" + FILE1).call();
}
clickCompareWith(compareWithIndexActionLabel);
assertTreeCompareNoChange();
// reset -> there should be no more changes
ResetOperation rop = new ResetOperation(lookupRepository(repositoryFile), "refs/heads/master", ResetType.HARD);
rop.execute(new NullProgressMonitor());
clickCompareWith(compareWithIndexActionLabel);
assertTreeCompareNoChange();
}
use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class ResetOperationTest method testSoftReset.
@Test
public void testSoftReset() throws Exception {
setupRepository();
String fileInIndexPath = fileInIndex.getLocation().toPortableString();
new ResetOperation(repository, initialCommit.getName(), ResetType.SOFT).execute(null);
// .project must remain
assertTrue(projectFile.exists());
assertTrue(project.getProject().exists());
// check if HEAD points to initial commit now
assertTrue(repository.resolve("HEAD").equals(initialCommit));
// untrackedFile and fileInIndex must still exist
assertTrue(untrackedFile.exists());
assertTrue(fileInIndex.exists());
// fileInIndex must no longer be in HEAD
assertFalse(testRepository.inHead(fileInIndexPath));
// fileInIndex must exist in the index
assertTrue(testRepository.inIndex(fileInIndexPath));
}
use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class ResetOperationTest method testHardReset.
@Test
public void testHardReset() throws Exception {
setupRepository();
String fileInIndexPath = fileInIndex.getLocation().toPortableString();
new ResetOperation(repository, initialCommit.getName(), ResetType.HARD).execute(null);
// .project must disappear, related Eclipse project must be deleted
assertFalse(projectFile.exists());
assertFalse(project.getProject().exists());
// check if HEAD points to initial commit now
assertTrue(repository.resolve("HEAD").equals(initialCommit));
// check if files were removed
assertFalse(untrackedFile.exists());
assertFalse(fileInIndex.exists());
// fileInIndex must no longer be in HEAD and in the index
assertFalse(testRepository.inHead(fileInIndexPath));
assertFalse(testRepository.inIndex(fileInIndexPath));
}
use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class CleanupUncomittedChangesDialog method buttonPressed.
@Override
protected void buttonPressed(int buttonId) {
switch(buttonId) {
case IDialogConstants.PROCEED_ID:
CommitUI commitUI = new CommitUI(getShell(), repository, new IResource[0], true);
shouldContinue = commitUI.commit();
break;
case IDialogConstants.ABORT_ID:
final ResetOperation operation = new ResetOperation(repository, Constants.HEAD, ResetType.HARD);
String jobname = NLS.bind(UIText.ResetAction_reset, Constants.HEAD);
JobUtil.scheduleUserWorkspaceJob(operation, jobname, JobFamilies.RESET);
shouldContinue = true;
break;
case IDialogConstants.SKIP_ID:
StashCreateUI stashCreateUI = new StashCreateUI(repository);
shouldContinue = stashCreateUI.createStash(getShell());
break;
case IDialogConstants.CANCEL_ID:
default:
break;
}
super.buttonPressed(buttonId);
}
use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class CompareActionsTest method testCompareWithHead.
@Test
public void testCompareWithHead() throws Exception {
String compareWithHeadMenuLabel = util.getPluginLocalizedValue("CompareWithHeadAction_label");
clickCompareWithAndWaitForSync(compareWithHeadMenuLabel);
closeFirstEmptySynchronizeDialog();
assertSynchronizeNoChange();
// change test file -> should have one change
setTestFileContent("Hello there");
clickCompareWithAndWaitForSync(compareWithHeadMenuLabel);
assertSynchronizeFile1Changed();
// add to index -> should still show as change
try (Git git = new Git(lookupRepository(repositoryFile))) {
git.add().addFilepattern(PROJ1 + "/" + FOLDER + "/" + FILE1).call();
}
clickCompareWithAndWaitForSync(compareWithHeadMenuLabel);
assertSynchronizeFile1Changed();
// reset -> there should be no more changes
ResetOperation rop = new ResetOperation(lookupRepository(repositoryFile), "refs/heads/master", ResetType.HARD);
rop.execute(new NullProgressMonitor());
clickCompareWithAndWaitForSync(compareWithHeadMenuLabel);
assertSynchronizeNoChange();
}
Aggregations