use of org.eclipse.jgit.api.RebaseResult in project egit by eclipse.
the class FeatureRebaseOperationTest method testFeatureRebase.
@Test
public void testFeatureRebase() throws Exception {
Repository repository = testRepository.getRepository();
GitFlowRepository gfRepo = init("testFeatureRebase\n\nfirst commit\n");
RevCommit initialCommit = gfRepo.findHead();
new FeatureStartOperation(gfRepo, MY_FEATURE).execute(null);
String branchCommitMessage = "adding first file on feature branch";
addFileAndCommit("theFile.txt", branchCommitMessage);
testRepository.checkoutBranch(gfRepo.getConfig().getDevelop());
RevCommit developCommit = addFileAndCommit("theOtherFile.txt", "adding second file on develop branch");
new FeatureCheckoutOperation(gfRepo, MY_FEATURE).execute(null);
assertEquals(initialCommit, gfRepo.findHead().getParent(0));
FeatureRebaseOperation featureRebaseOperation = new FeatureRebaseOperation(gfRepo);
featureRebaseOperation.execute(null);
RebaseResult res = featureRebaseOperation.getOperationResult();
assertEquals(RebaseResult.Status.OK, res.getStatus());
assertEquals(branchCommitMessage, gfRepo.findHead().getShortMessage());
assertEquals(developCommit, parseCommit(repository, repository.resolve("HEAD^")));
}
use of org.eclipse.jgit.api.RebaseResult in project egit by eclipse.
the class MultiPullResultDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().applyTo(main);
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
tv = new TableViewer(main, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
tv.setContentProvider(ArrayContentProvider.getInstance());
TableColumnLayout layout = new TableColumnLayout();
main.setLayout(layout);
tv.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
boolean enabled = false;
for (Object obj : sel.toList()) {
@SuppressWarnings("unchecked") Entry<Repository, Object> entry = (Entry<Repository, Object>) obj;
enabled |= entry.getValue() instanceof PullResult;
}
getButton(DETAIL_BUTTON).setEnabled(enabled);
}
});
tv.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
buttonPressed(DETAIL_BUTTON);
}
});
Table table = tv.getTable();
int linesToShow = Math.min(Math.max(results.size(), 5), 15);
int heightHint = table.getItemHeight() * linesToShow;
GridDataFactory.fillDefaults().grab(true, true).hint(800, heightHint).applyTo(table);
// repository
TableViewerColumn tc = new TableViewerColumn(tv, SWT.NONE);
TableColumn col = tc.getColumn();
tc.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
@SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
return utils.getRepositoryName(item.getKey());
}
});
col.setText(UIText.MultiPullResultDialog_RepositoryColumnHeader);
layout.setColumnData(col, new ColumnWeightData(200, 200));
createComparator(col, 0);
// fetch status
tc = new TableViewerColumn(tv, SWT.NONE);
col = tc.getColumn();
tc.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
@SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
if (item.getValue() instanceof IStatus)
return UIText.MultiPullResultDialog_UnknownStatus;
PullResult pullRes = (PullResult) item.getValue();
if (pullRes.getFetchResult() == null) {
return UIText.MultiPullResultDialog_NothingFetchedStatus;
} else if (pullRes.getFetchResult().getTrackingRefUpdates().isEmpty()) {
return UIText.MultiPullResultDialog_NothingUpdatedStatus;
} else {
int updated = pullRes.getFetchResult().getTrackingRefUpdates().size();
if (updated == 1) {
return UIText.MultiPullResultDialog_UpdatedOneMessage;
}
return NLS.bind(UIText.MultiPullResultDialog_UpdatedMessage, Integer.valueOf(updated));
}
}
});
col.setText(UIText.MultiPullResultDialog_FetchStatusColumnHeader);
layout.setColumnData(col, new ColumnWeightData(200, 200));
createComparator(col, 1);
// update status
tc = new TableViewerColumn(tv, SWT.NONE);
col = tc.getColumn();
tc.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
@SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
if (item.getValue() instanceof IStatus) {
return UIText.MultiPullResultDialog_UnknownStatus;
}
PullResult pullRes = (PullResult) item.getValue();
if (pullRes.getMergeResult() != null) {
return NLS.bind(UIText.MultiPullResultDialog_MergeResultMessage, MergeResultDialog.getStatusText(pullRes.getMergeResult().getMergeStatus()));
} else if (pullRes.getRebaseResult() != null) {
RebaseResult res = pullRes.getRebaseResult();
return NLS.bind(UIText.MultiPullResultDialog_RebaseResultMessage, RebaseResultDialog.getStatusText(res.getStatus()));
} else {
return UIText.MultiPullResultDialog_NothingUpdatedStatus;
}
}
});
col.setText(UIText.MultiPullResultDialog_UpdateStatusColumnHeader);
layout.setColumnData(col, new ColumnWeightData(200, 200));
createComparator(col, 2);
// overall status
tc = new TableViewerColumn(tv, SWT.NONE);
col = tc.getColumn();
tc.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
@SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
Object resultOrError = item.getValue();
if (resultOrError instanceof IStatus) {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_STOP);
}
PullResult res = (PullResult) item.getValue();
boolean success = res.isSuccessful();
if (!success) {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_STOP);
}
return null;
}
@Override
public String getText(Object element) {
@SuppressWarnings("unchecked") Entry<Repository, Object> item = (Entry<Repository, Object>) element;
if (item.getValue() instanceof IStatus) {
IStatus status = (IStatus) item.getValue();
return status.getMessage();
}
PullResult res = (PullResult) item.getValue();
if (res.isSuccessful()) {
return UIText.MultiPullResultDialog_OkStatus;
} else {
return UIText.MultiPullResultDialog_FailedStatus;
}
}
});
col.setText(UIText.MultiPullResultDialog_OverallStatusColumnHeader);
layout.setColumnData(col, new ColumnWeightData(200, 200));
createComparator(col, 3);
table.setHeaderVisible(true);
table.setLinesVisible(true);
tv.setInput(results.entrySet());
return main;
}
Aggregations