use of org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory in project egit by eclipse.
the class GitScopeUtilTest method setup.
@Before
public void setup() throws Exception {
SWTBotView view = TestUtil.showExplorerView();
part = view.getViewReference().getPart(false);
repositoryFile = createProjectAndCommitToRepository();
GitScopeOperationFactory.setFactory(new GitScopeOperationFactory() {
@Override
public GitScopeOperation createGitScopeOperation(IWorkbenchPart workbenchPart, SubscriberScopeManager manager) {
return new GitScopeOperation(workbenchPart, manager) {
@Override
protected boolean promptForInputChange(String requestPreviewMessage, IProgressMonitor monitor) {
// we will avoid the confirmation prompt in the tests
return false;
}
};
}
});
}
use of org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory in project egit by eclipse.
the class GitScopeUtilTest method relatedChangesWithPrompt.
@Test
public void relatedChangesWithPrompt() throws Exception {
GitScopeOperationFactory.setFactory(new GitScopeOperationFactory());
final IFile modelFile = createModelFiles();
Repository repository = lookupRepository(repositoryFile);
Activator.getDefault().getIndexDiffCache().getIndexDiffCacheEntry(repository);
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
final IResource[] selectedResources = new IResource[] { modelFile };
UIThreadRunnable.asyncExec(new VoidResult() {
@Override
public void run() {
try {
GitScopeUtil.getRelatedChanges(part, selectedResources);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
// Prompt because the files are untracked
SWTBotShell dialog = bot.shell("Selection Adjustment Required");
dialog.bot().button(IDialogConstants.OK_LABEL).click();
IFile modelExtensionsFile = modelFile.getProject().getFile(MODEL_EXTENSIONS_FILE);
addAndCommit(modelExtensionsFile, "add model extensions file");
addAndCommit(modelFile, "add model file");
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
// Both files are committed, should no longer prompt now
IResource[] relatedChanges = getRelatedChangesInUIThread(selectedResources);
assertEquals(2, relatedChanges.length);
assertContainsResourceByName(relatedChanges, MODEL_FILE);
assertContainsResourceByName(relatedChanges, MODEL_EXTENSIONS_FILE);
}
Aggregations