}
public Repository createRepository(String name)
throws RepositoryNotFoundException {
if (isUnreasonableName(name)) {
throw new RepositoryNotFoundException("Invalid name: " + name);
}
try {
File dir = FileKey.resolve(gitDirOf(name), FS.DETECTED);
FileKey loc;
if (dir != null) {
// Already exists on disk, use the repository we found.
//
loc = FileKey.exact(dir, FS.DETECTED);
} else {
// It doesn't exist under any of the standard permutations
// of the repository name, so prefer the standard bare name.
//
if (!name.endsWith(Constants.DOT_GIT_EXT)) {
name = name + Constants.DOT_GIT_EXT;
}
loc = FileKey.exact(new File(basePath, name), FS.DETECTED);
}
return RepositoryCache.open(loc, false);
} catch (IOException e1) {
final RepositoryNotFoundException e2;
e2 = new RepositoryNotFoundException("Cannot open repository " + name);
e2.initCause(e1);
throw e2;
}
}