Index: plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java =================================================================== --- plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java (revision 41767) +++ plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java (working copy) @@ -204,31 +204,46 @@ throw new CoreException(new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, NLS.bind("No repository found for project {0}. Please ensure it is shared via git.", p.getName()))); } - try { + + if( changed != 0 && requestCommitAndPushApproval(p.getName(), changed)) { monitor.beginTask("Publishing " + p.getName(), 300); EGitUtils.commit(p, new SubProgressMonitor(monitor, 100)); committed = true; } - + + try { + if( committed || (changed == 0 && requestPushApproval(p.getName()))) { if( !committed ) monitor.beginTask("Publishing " + p.getName(), 200); result = EGitUtils.push(remoteName, repo, new SubProgressMonitor(monitor, 100)); monitor.done(); + + } + + } catch(CoreException ce) { - // Comes if either commit or push has failed - if( ce.getMessage().contains("UP_TO_DATE")) + // Comes if push has failed + if( ce.getMessage()!=null && ce.getMessage().contains("UP_TO_DATE")) { + ConsoleUtils.appendToConsole(behaviour.getServer(), "\nRepository already uptodate."); return null; + } try { - result = EGitUtils.pushForce(remoteName, repo, new SubProgressMonitor(monitor, 100)); + if(requestApproval("Error: '" + ce.getMessage() + "' occurred while pushing.\n\nIf the commit history is not correct on the remote repository, a forced push (git push -f) might be the right thing to do. This will though overwrite the remote repository!\n\n Do you want to do a forced push ? ", "Attempt push force ?")) { + result = EGitUtils.pushForce(remoteName, repo, new SubProgressMonitor(monitor, 100)); + } monitor.done(); } catch(CoreException ce2) { - // even the push force failed, and we don't have a valid result to check :( - // can only throw it i guess - throw ce2; + if( ce.getMessage()!=null && ce.getMessage().contains("UP_TO_DATE")) { + ConsoleUtils.appendToConsole(behaviour.getServer(), "\n(Forced push) Repository already uptodate."); + return null; + } else { + // even the push force failed, and we don't have a valid result to check :( + throw ce2; + } } }