Merge "StringIndexOutOfBoundsException if repository named .git exists"
This commit is contained in:
@@ -357,7 +357,9 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
|
|||||||
|
|
||||||
for (File f : ls) {
|
for (File f : ls) {
|
||||||
String fileName = f.getName();
|
String fileName = f.getName();
|
||||||
if (FileKey.isGitRepository(f, FS.DETECTED)) {
|
if (fileName.equals(Constants.DOT_GIT)) {
|
||||||
|
// Skip repositories named only `.git`
|
||||||
|
} else if (FileKey.isGitRepository(f, FS.DETECTED)) {
|
||||||
Project.NameKey nameKey = getProjectName(prefix, fileName);
|
Project.NameKey nameKey = getProjectName(prefix, fileName);
|
||||||
if (isUnreasonableName(nameKey)) {
|
if (isUnreasonableName(nameKey)) {
|
||||||
log.warn("Ignoring unreasonably named repository " + f.getAbsolutePath());
|
log.warn("Ignoring unreasonably named repository " + f.getAbsolutePath());
|
||||||
@@ -374,10 +376,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
|
|||||||
private Project.NameKey getProjectName(final String prefix,
|
private Project.NameKey getProjectName(final String prefix,
|
||||||
final String fileName) {
|
final String fileName) {
|
||||||
final String projectName;
|
final String projectName;
|
||||||
if (fileName.equals(Constants.DOT_GIT)) {
|
if (fileName.endsWith(Constants.DOT_GIT_EXT)) {
|
||||||
projectName = prefix.substring(0, prefix.length() - 1);
|
|
||||||
|
|
||||||
} else if (fileName.endsWith(Constants.DOT_GIT_EXT)) {
|
|
||||||
int newLen = fileName.length() - Constants.DOT_GIT_EXT.length();
|
int newLen = fileName.length() - Constants.DOT_GIT_EXT.length();
|
||||||
projectName = prefix + fileName.substring(0, newLen);
|
projectName = prefix + fileName.substring(0, newLen);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user