Fix calculation of project name if repo is not existing

The calculation of the project name in LocalDiskRepositoryManager
assumes that the relative path to the git repository ends with a
slash. This is only true if the repository exists in the file system.
If a project inherits from a non existing parent (the inheritFrom in
project.config points to a non existing parent), we try to lookup a
non existing repository. In this case the relative path is just the
project name without any '/' in the end. As result the code fails
with a StringIndexOutOfBoundsException.

Change-Id: Id48c0708d077a75adc6f9ab9dbd91d051959d43c
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2011-10-28 04:27:16 +02:00
parent 3ef3c7ae9b
commit b57de70331

View File

@@ -298,8 +298,11 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
}
private Project.NameKey getProjectName(final File gitDir) {
final String relativeGitPath =
String relativeGitPath =
getBasePath().toURI().relativize(gitDir.toURI()).getPath();
if (!relativeGitPath.endsWith("/")) {
relativeGitPath = relativeGitPath + "/";
}
final String prefix =
relativeGitPath.substring(0, relativeGitPath.length() - 1
- gitDir.getName().length());