use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class ResetOperationTest method testMixedReset.
@Test
public void testMixedReset() throws Exception {
setupRepository();
String fileInIndexPath = fileInIndex.getLocation().toPortableString();
new ResetOperation(repository, initialCommit.getName(), ResetType.MIXED).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 not in the index
assertFalse(testRepository.inIndex(fileInIndexPath));
}
use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class ResetActionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Repository repository = getRepository(true, event);
if (repository == null)
return null;
if (!repository.getRepositoryState().canResetHead()) {
MessageDialog.openError(getShell(event), UIText.ResetAction_errorResettingHead, NLS.bind(UIText.ResetAction_repositoryState, repository.getRepositoryState().getDescription()));
return null;
}
ResetTargetSelectionDialog branchSelectionDialog = new ResetTargetSelectionDialog(getShell(event), repository);
if (branchSelectionDialog.open() == IDialogConstants.OK_ID) {
final String refName = branchSelectionDialog.getRefName();
final ResetType type = branchSelectionDialog.getResetType();
String jobname = NLS.bind(UIText.ResetAction_reset, refName);
final ResetOperation operation = new ResetOperation(repository, refName, type);
JobUtil.scheduleUserWorkspaceJob(operation, jobname, JobFamilies.RESET);
}
return null;
}
use of org.eclipse.egit.core.op.ResetOperation in project egit by eclipse.
the class ResetMenu method performReset.
/**
* @param shell
* @param repo
* @param commitId
* @param resetType
*/
public static void performReset(Shell shell, final Repository repo, final ObjectId commitId, ResetType resetType) {
final String jobName;
switch(resetType) {
case HARD:
if (!CommandConfirmation.confirmHardReset(shell, repo)) {
return;
}
jobName = UIText.HardResetToRevisionAction_hardReset;
break;
case SOFT:
jobName = UIText.SoftResetToRevisionAction_softReset;
break;
case MIXED:
jobName = UIText.MixedResetToRevisionAction_mixedReset;
break;
default:
// other types are currently not used
return;
}
ResetOperation operation = new ResetOperation(repo, commitId.getName(), resetType);
JobUtil.scheduleUserWorkspaceJob(operation, jobName, JobFamilies.RESET);
}
Aggregations