Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JBIDE-15059] fetching after push so that isAhead-state gets updated #184

Merged
merged 1 commit into from
Jun 29, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.jboss.tools.openshift.express.internal.core.behaviour;

import java.io.File;
import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
Expand All @@ -29,6 +30,7 @@
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -256,6 +258,7 @@ protected PushOperationResult push(IProject project, IServer server, IProgressMo
PushOperationResult result = EGitUtils.push(
remoteName, repository, new SubProgressMonitor(monitor, 100),
ConsoleUtils.getConsoleOutputStream(server));
safeFetch(remoteName, repository, monitor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't in be wrapped in SafeRunnable instead? To avoid catching generic Exception in private method?

monitor.done();
return result;
} catch (CoreException ce) {
Expand Down Expand Up @@ -305,6 +308,33 @@ remoteName, repository, new SubProgressMonitor(monitor, 100),
}
}

/**
* Workaround needed to get correct "isAhead" state for the repository we
* were pushing to. Otherwise git branch state will be erroneous compared to
* the remote, behave as if we did not push yet.
*
* @param remoteName
* the remote to push to
* @param repository
* the repository to push
* @param monitor
* the montior to report progress to
*
* @see <a href="https://issues.jboss.org/browse/JBIDE-15059">https://issues.jboss.org/browse/JBIDE-15059</a>
*/
private void safeFetch(String remoteName, Repository repository, IProgressMonitor monitor) {
try {
RemoteConfig remoteConfig = EGitUtils.getRemoteConfig(remoteName, EGitUtils.getAllRemoteConfigs(repository));
EGitUtils.fetch(remoteConfig, repository, monitor);
} catch (CoreException e) {
OpenShiftUIActivator.log(
NLS.bind("Could not get remote configs for repository {0}", repository.getDirectory()), e);
} catch (InvocationTargetException e) {
OpenShiftUIActivator.log(
NLS.bind("Could not fetch remote {0} for repository {1}", remoteName, repository.getDirectory()), e);
}
}

protected String getModuleProjectName(IModule[] module) {
return module[module.length - 1].getProject().getName();
}
Expand Down