Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-07-01 16:34:57 -0400
committerThomas Wolf2019-07-03 03:04:35 -0400
commitcd2aeaa7c9ebaa04e535eb9e177b5d8b979e0dc0 (patch)
treefa0dde44d79baf64cd13a22b11eb63102dc3ad91 /org.eclipse.egit.ui/src/org/eclipse
parent19726c3b28bd4cdabaa9cad3f88c995ccb387d8b (diff)
downloadegit-cd2aeaa7c9ebaa04e535eb9e177b5d8b979e0dc0.tar.gz
egit-cd2aeaa7c9ebaa04e535eb9e177b5d8b979e0dc0.tar.xz
egit-cd2aeaa7c9ebaa04e535eb9e177b5d8b979e0dc0.zip
Repositories view: check for submodules when reacting on selection
When the repositories was set to follow the selection and a file in a submodule folder was selected, the submodule repository was added as a top-level repository in the view. Fix this by also considering repositories under submodule nodes when determining which node to show. Add a new test, and fix SubmoduleFolderTest to properly commit the addition of the submodule in setUp(). Bug: 520735 Change-Id: I54c1d2c5d2b8fac95dc7a4fed658e59285639f4c Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java55
1 files changed, 42 insertions, 13 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index 908ea7564..e1da30586 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -631,13 +631,13 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
private boolean checkNotConfiguredRepositories(
Map<Repository, Collection<String>> pathsByRepo) {
boolean added = false;
- for (Map.Entry<Repository, Collection<String>> entry : pathsByRepo.entrySet()) {
- Repository repository = entry.getKey();
+ for (Repository repository : pathsByRepo.keySet()) {
try {
- boolean newOne = repositoryUtil
- .addConfiguredRepository(repository.getDirectory());
- if (newOne) {
- added = true;
+ RepositoryTreeNode node = getRepositoryChildNode(repository,
+ RepositoryTreeNodeType.WORKINGDIR);
+ if (node == null) {
+ added |= repositoryUtil
+ .addConfiguredRepository(repository.getDirectory());
}
} catch (IllegalArgumentException iae) {
Activator.handleError(iae.getMessage(), iae, false);
@@ -1005,16 +1005,43 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
RepositoryTreeNodeType type) {
ITreeContentProvider cp = (ITreeContentProvider) getCommonViewer()
.getContentProvider();
- for (Object repo : cp.getElements(getCommonViewer().getInput())) {
+ RepositoryTreeNode repoNode = findRepositoryNode(cp,
+ cp.getElements(getCommonViewer().getInput()), repository);
+ return repoNode == null ? null : findChild(cp, repoNode, type);
+ }
+
+ private RepositoryTreeNode findChild(ITreeContentProvider cp,
+ RepositoryTreeNode root, RepositoryTreeNodeType type) {
+ for (Object child : cp.getChildren(root)) {
+ RepositoryTreeNode childNode = (RepositoryTreeNode) child;
+ if (childNode.getType() == type) {
+ return childNode;
+ }
+ }
+ return null;
+ }
+
+ private RepositoryTreeNode findRepositoryNode(
+ ITreeContentProvider cp, Object[] roots,
+ Repository repository) {
+ for (Object repo : roots) {
RepositoryTreeNode node = (RepositoryTreeNode) repo;
// TODO equals implementation of Repository?
if (repository.getDirectory().equals(
((Repository) node.getObject()).getDirectory())) {
- for (Object child : cp.getChildren(node)) {
- RepositoryTreeNode childNode = (RepositoryTreeNode) child;
- if (childNode.getType() == type) {
- return childNode;
- }
+ return node;
+ }
+ }
+ // Might be a submodule
+ for (Object repo : roots) {
+ RepositoryTreeNode node = (RepositoryTreeNode) repo;
+ RepositoryTreeNode submodules = findChild(cp, node,
+ RepositoryTreeNodeType.SUBMODULES);
+ if (submodules != null) {
+ RepositoryTreeNode submoduleNode = findRepositoryNode(cp,
+ cp.getChildren(submodules), repository);
+ if (submoduleNode != null) {
+ return submoduleNode;
}
}
}
@@ -1025,7 +1052,9 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
String repoRelativePath) {
RepositoryTreeNode currentNode = getRepositoryChildNode(repository,
RepositoryTreeNodeType.WORKINGDIR);
-
+ if (currentNode == null) {
+ return null;
+ }
ITreeContentProvider cp = (ITreeContentProvider) getCommonViewer()
.getContentProvider();
IPath relPath = new Path(repoRelativePath);

Back to the top