private RepositoryModel loadRepositoryModel(String repositoryName) {
Repository r = getRepository(repositoryName);
if (r == null) {
return null;
}
RepositoryModel model = new RepositoryModel();
model.isBare = r.isBare();
File basePath = getRepositoriesFolder();
if (model.isBare) {
model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());
} else {
model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());
}
if (StringUtils.isEmpty(model.name)) {
// Repository is NOT located relative to the base folder because it
// is symlinked. Use the provided repository name.
model.name = repositoryName;
}
model.projectPath = StringUtils.getFirstPathElement(repositoryName);
StoredConfig config = r.getConfig();
boolean hasOrigin = false;
if (config != null) {
// Initialize description from description file
hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
if (getConfig(config,"description", null) == null) {
File descFile = new File(r.getDirectory(), "description");
if (descFile.exists()) {
String desc = com.gitblit.utils.FileUtils.readContent(descFile, System.getProperty("line.separator"));
if (!desc.toLowerCase().startsWith("unnamed repository")) {
config.setString(Constants.CONFIG_GITBLIT, null, "description", desc);
}
}
}
model.description = getConfig(config, "description", "");
model.originRepository = getConfig(config, "originRepository", null);
model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
model.acceptNewPatchsets = getConfig(config, "acceptNewPatchsets", true);
model.acceptNewTickets = getConfig(config, "acceptNewTickets", true);
model.requireApproval = getConfig(config, "requireApproval", settings.getBoolean(Keys.tickets.requireApproval, false));
model.mergeTo = getConfig(config, "mergeTo", null);
model.useIncrementalPushTags = getConfig(config, "useIncrementalPushTags", false);