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:
@@ -298,8 +298,11 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Project.NameKey getProjectName(final File gitDir) {
|
private Project.NameKey getProjectName(final File gitDir) {
|
||||||
final String relativeGitPath =
|
String relativeGitPath =
|
||||||
getBasePath().toURI().relativize(gitDir.toURI()).getPath();
|
getBasePath().toURI().relativize(gitDir.toURI()).getPath();
|
||||||
|
if (!relativeGitPath.endsWith("/")) {
|
||||||
|
relativeGitPath = relativeGitPath + "/";
|
||||||
|
}
|
||||||
final String prefix =
|
final String prefix =
|
||||||
relativeGitPath.substring(0, relativeGitPath.length() - 1
|
relativeGitPath.substring(0, relativeGitPath.length() - 1
|
||||||
- gitDir.getName().length());
|
- gitDir.getName().length());
|
||||||
|
|||||||
Reference in New Issue
Block a user