use of org.eclipse.jgit.transport.FetchResult in project egit by eclipse.
the class FetchOperationUI method start.
/**
* Starts the operation asynchronously showing a confirmation dialog after
* completion
*/
public void start() {
final Repository repo = repository;
if (repo == null) {
return;
}
Job job = new RepositoryJob(NLS.bind(UIText.FetchOperationUI_FetchJobName, sourceString), UIPreferences.SHOW_FETCH_POPUP_SUCCESS) {
private FetchResult result;
@Override
public IStatus performJob(IProgressMonitor monitor) {
try {
result = execute(monitor);
} catch (CoreException e) {
return Activator.createErrorStatus(e.getStatus().getMessage(), e);
}
return Status.OK_STATUS;
}
@Override
protected IAction getAction() {
return new ShowResultAction(repo, result, sourceString);
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.FETCH.equals(family)) {
return true;
}
return super.belongsTo(family);
}
};
job.setUser(true);
job.schedule();
}
use of org.eclipse.jgit.transport.FetchResult in project egit by eclipse.
the class FeatureTrackOperationTest method testFeatureTrack.
@Test
public void testFeatureTrack() throws Exception {
GitFlowRepository gfRepo1 = new GitFlowRepository(repository1.getRepository());
GitFlowRepository gfRepo2 = new GitFlowRepository(repository2.getRepository());
new FeatureStartOperation(gfRepo1, MY_FEATURE).execute(null);
RevCommit branchCommit = repository1.createInitialCommit("testFeatureTrack");
FeatureTrackOperation featureTrackOperation = new FeatureTrackOperation(gfRepo2, getFirstRemoteFeatureRef(gfRepo2), NO_TIMEOUT);
featureTrackOperation.execute(null);
FetchResult operationResult = featureTrackOperation.getOperationResult();
assertNotNull(operationResult.getAdvertisedRef(gfRepo2.getConfig().getFullFeatureBranchName(MY_FEATURE)));
assertEquals(gfRepo2.getConfig().getFeatureBranchName(MY_FEATURE), repository2.getRepository().getBranch());
assertEquals(branchCommit, findHead(repository2.getRepository()));
RevCommit localCommit = repository2.createInitialCommit("testFeatureTrack2");
new CurrentBranchPublishOperation(gfRepo2, 0).execute(null);
assertEquals(localCommit, findHead(repository2.getRepository()));
// config updated?
assertEquals(DEFAULT_REMOTE_NAME, getRemoteName(gfRepo2, MY_FEATURE));
assertEquals(R_HEADS + gfRepo2.getConfig().getFeatureBranchName(MY_FEATURE), gfRepo2.getUpstreamBranchName(MY_FEATURE));
}
use of org.eclipse.jgit.transport.FetchResult in project egit by eclipse.
the class PullResultDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
GridLayoutFactory.swtDefaults().applyTo(main);
GridDataFactory.fillDefaults().indent(0, 0).grab(true, true).applyTo(main);
Group fetchResultGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
fetchResultGroup.setText(UIText.PullResultDialog_FetchResultGroupHeader);
GridLayoutFactory.fillDefaults().applyTo(fetchResultGroup);
GridDataFactory.fillDefaults().grab(true, true).applyTo(fetchResultGroup);
FetchResult fRes = result.getFetchResult();
if (hasFetchResults()) {
GridLayoutFactory.fillDefaults().applyTo(fetchResultGroup);
FetchResultDialog dlg = new FetchResultDialog(getParentShell(), repo, fRes, result.getFetchedFrom());
Control fresult = dlg.createFetchResultTable(fetchResultGroup);
Object layoutData = fresult.getLayoutData();
if (layoutData instanceof GridData)
GridDataFactory.createFrom((GridData) layoutData).hint(SWT.DEFAULT, 130).applyTo(fresult);
} else {
GridLayoutFactory.swtDefaults().applyTo(fetchResultGroup);
Label noResult = new Label(fetchResultGroup, SWT.NONE);
if (// $NON-NLS-1$
result.getFetchedFrom().equals("."))
noResult.setText(UIText.PullResultDialog_NothingToFetchFromLocal);
else
noResult.setText(NLS.bind(UIText.FetchResultDialog_labelEmptyResult, result.getFetchedFrom()));
}
Group mergeResultGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
mergeResultGroup.setText(UIText.PullResultDialog_MergeResultGroupHeader);
if (hasMergeResults()) {
GridDataFactory.fillDefaults().grab(true, true).applyTo(mergeResultGroup);
GridLayoutFactory.fillDefaults().applyTo(mergeResultGroup);
MergeResultDialog dlg = new MergeResultDialog(getParentShell(), repo, result.getMergeResult());
dlg.createDialogArea(mergeResultGroup);
} else if (hasRebaseResults()) {
RebaseResultDialog.createFailedOrConflictsParts(mergeResultGroup, result.getRebaseResult());
GridDataFactory.fillDefaults().grab(true, false).applyTo(mergeResultGroup);
} else {
GridDataFactory.fillDefaults().grab(true, false).applyTo(mergeResultGroup);
GridLayoutFactory.swtDefaults().applyTo(mergeResultGroup);
Label noResult = new Label(mergeResultGroup, SWT.NONE);
noResult.setText(UIText.PullResultDialog_MergeAlreadyUpToDateMessage);
}
return main;
}
use of org.eclipse.jgit.transport.FetchResult in project statecharts by Yakindu.
the class GitRepositoryExampleService method isUpToDate.
@Override
public boolean isUpToDate(IProgressMonitor monitor) {
java.nio.file.Path storageLocation = getStorageLocation();
try {
FetchCommand fetch = Git.open(storageLocation.toFile()).fetch();
FetchResult result = fetch.setProgressMonitor(new EclipseGitProgressTransformer(monitor)).setDryRun(true).call();
Collection<TrackingRefUpdate> trackingRefUpdates = result.getTrackingRefUpdates();
return trackingRefUpdates.size() == 0;
} catch (RepositoryNotFoundException ex) {
// This is the case when the examples are imported manually
return true;
} catch (Exception ex) {
ex.printStackTrace();
return true;
}
}
use of org.eclipse.jgit.transport.FetchResult in project gerrit by GerritCodeReview.
the class GitUtil method cloneProject.
public static TestRepository<InMemoryRepository> cloneProject(Project.NameKey project, String uri) throws Exception {
DfsRepositoryDescription desc = new DfsRepositoryDescription("clone of " + project.get());
InMemoryRepository.Builder b = new InMemoryRepository.Builder().setRepositoryDescription(desc);
if (uri.startsWith("ssh://")) {
// SshTransport depends on a real FS to read ~/.ssh/config, but InMemoryRepository by default
// uses a null FS.
// Avoid leaking user state into our tests.
b.setFS(FS.detect().setUserHome(null));
}
InMemoryRepository dest = b.build();
Config cfg = dest.getConfig();
cfg.setString("remote", "origin", "url", uri);
cfg.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*");
TestRepository<InMemoryRepository> testRepo = newTestRepository(dest);
FetchResult result = testRepo.git().fetch().setRemote("origin").call();
String originMaster = "refs/remotes/origin/master";
if (result.getTrackingRefUpdate(originMaster) != null) {
testRepo.reset(originMaster);
}
return testRepo;
}
Aggregations