Author: adietish
Date: 2012-02-08 09:11:46 -0500 (Wed, 08 Feb 2012)
New Revision: 38502
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
Log:
[JBIDE-10479] implemented EGitUtils#hasRemote(name, url) that reponds whether a repo has a
configured remote with the given name and url
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-02-08
14:04:51 UTC (rev 38501)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-02-08
14:11:46 UTC (rev 38502)
@@ -408,13 +408,13 @@
*/
public static PushOperationResult push(String remote, Repository repository,
IProgressMonitor monitor)
throws CoreException {
- RemoteConfig remoteConfig = getRemoteConfig(remote, repository);
+ RemoteConfig remoteConfig = getRemoteByName(remote, repository);
return push(repository, remoteConfig, false, monitor);
}
public static PushOperationResult pushForce(String remote, Repository repository,
IProgressMonitor monitor)
throws CoreException {
- RemoteConfig remoteConfig = getRemoteConfig(remote, repository);
+ RemoteConfig remoteConfig = getRemoteByName(remote, repository);
return push(repository, remoteConfig, true, monitor);
}
@@ -634,7 +634,7 @@
String currentBranch = getCurrentBranch(repository);
String remote = getRemoteName(currentBranch, repository);
- return getRemoteConfig(remote, repository);
+ return getRemoteByName(remote, repository);
}
/**
@@ -645,7 +645,7 @@
* @return
* @throws CoreException
*/
- private static RemoteConfig getRemoteConfig(String remote, Repository repository) throws
CoreException {
+ private static RemoteConfig getRemoteByName(String remote, Repository repository) throws
CoreException {
Assert.isLegal(repository != null, "Could not get configuration. No repository
provided.");
List<RemoteConfig> allRemotes = getAllRemoteConfigs(repository);
@@ -705,21 +705,20 @@
}
/**
- * Returns <code>true</code> if the given repository has a configured
remote
- * repository with an url that matches the given pattern.
+ * Returns the first configured remote in the given repository whose url matches the
given pattern.
*
* @param pattern
* @param repository
* @return
* @throws CoreException
*/
- public static boolean hasRemoteUrl(Pattern pattern, Repository repository) throws
CoreException {
+ public static RemoteConfig getRemoteByUrl(Pattern pattern, Repository repository) throws
CoreException {
for (RemoteConfig config : getAllRemoteConfigs(repository)) {
if (hasRemoteUrl(pattern, config)) {
- return true;
+ return config;
}
}
- return false;
+ return null;
}
public static boolean hasRemoteUrl(Pattern pattern, RemoteConfig config) {
@@ -733,6 +732,21 @@
}
/**
+ * Returns <code>true</code> if the given repository has a remote with the
+ * given name,
+ *
+ * @param name
+ * the remote name that we're looking for
+ * @param repository
+ * the repository to look at
+ * @return true if the given repo has a remote with the given name
+ * @throws CoreException
+ */
+ public static boolean hasRemote(String name, Repository repository) throws CoreException
{
+ return getRemoteByName(name, repository) != null;
+ }
+
+ /**
* Returns <code>true</code> if the given repository has a remote config
* with the given name and url.
*
@@ -746,7 +760,7 @@
* @throws CoreException
*/
public static boolean hasRemote(String name, String url, Repository repository) throws
CoreException {
- RemoteConfig remoteConfig = getRemoteConfig(name, repository);
+ RemoteConfig remoteConfig = getRemoteByName(name, repository);
if (remoteConfig == null) {
return false;
}