Author: adietish
Date: 2012-01-20 14:05:48 -0500 (Fri, 20 Jan 2012)
New Revision: 38004
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
Log:
[JBIDE-10479] refuse to import a project with uncommitted changes
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-01-20
17:43:54 UTC (rev 38003)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-01-20
19:05:48 UTC (rev 38004)
@@ -46,6 +46,7 @@
import org.eclipse.jgit.api.InitCommand;
import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.api.errors.JGitInternalException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
@@ -714,6 +715,25 @@
return status;
}
+ /**
+ * Returns <code>true</code> if the given repository has uncommitted
+ * changes.
+ *
+ * @param repository the repository to check for uncommitted changes
+ * @return
+ * @throws IOException
+ * @throws NoWorkTreeException
+ */
+ public static boolean isDirty(Repository repository) throws NoWorkTreeException,
IOException {
+ boolean hasChanges = false;
+ org.eclipse.jgit.api.Status repoStatus = new Git(repository).status().call();
+ hasChanges |= !repoStatus.getAdded().isEmpty();
+ hasChanges |= !repoStatus.getChanged().isEmpty();
+ hasChanges |= !repoStatus.getModified().isEmpty();
+ hasChanges |= repoStatus.getRemoved().isEmpty();
+ return hasChanges;
+ }
+
public static int countCommitableChanges(IProject project, IServer server,
IProgressMonitor monitor) {
try {
Set<String> commitable = getCommitableChanges(project, server, monitor);
Show replies by date