mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-01 21:29:47 +01:00
Refactor the repository store implementation in order to store repositories in specific paths.
This commit is contained in:
@@ -6,14 +6,11 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class GitConfigDto extends HalRepresentation {
|
||||
|
||||
private File repositoryDirectory;
|
||||
private boolean disabled = false;
|
||||
|
||||
private String gcExpression;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class GitRepositoryHandler
|
||||
GitRepositoryServiceProvider.COMMANDS);
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
|
||||
private final Scheduler scheduler;
|
||||
|
||||
private Task task;
|
||||
@@ -98,15 +98,15 @@ public class GitRepositoryHandler
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
* @param storeFactory
|
||||
* @param fileSystem
|
||||
* @param scheduler
|
||||
* @param repositoryLocationResolver
|
||||
*/
|
||||
@Inject
|
||||
public GitRepositoryHandler(ConfigurationStoreFactory storeFactory, FileSystem fileSystem, Scheduler scheduler)
|
||||
public GitRepositoryHandler(ConfigurationStoreFactory storeFactory, FileSystem fileSystem, Scheduler scheduler, RepositoryLocationResolver repositoryLocationResolver)
|
||||
{
|
||||
super(storeFactory, fileSystem);
|
||||
super(storeFactory, fileSystem, repositoryLocationResolver);
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
|
||||
|
||||
if (config.isValid())
|
||||
{
|
||||
File gitdir = findRepository(config.getRepositoryDirectory(), repo.getId());
|
||||
File gitdir = handler.getDirectory(repo);
|
||||
if (gitdir == null) {
|
||||
throw new RepositoryNotFoundException(repositoryName);
|
||||
}
|
||||
@@ -132,32 +132,6 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
File findRepository(File parentDirectory, String repositoryName) {
|
||||
File repositoryDirectory = new File(parentDirectory, repositoryName);
|
||||
if (repositoryDirectory.exists()) {
|
||||
return repositoryDirectory;
|
||||
}
|
||||
|
||||
if (endsWithDotGit(repositoryName)) {
|
||||
String repositoryNameWithoutDotGit = repositoryNameWithoutDotGit(repositoryName);
|
||||
repositoryDirectory = new File(parentDirectory, repositoryNameWithoutDotGit);
|
||||
if (repositoryDirectory.exists()) {
|
||||
return repositoryDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean endsWithDotGit(String repositoryName) {
|
||||
return repositoryName.endsWith(GitRepositoryHandler.DOT_GIT);
|
||||
}
|
||||
|
||||
private String repositoryNameWithoutDotGit(String repositoryName) {
|
||||
return repositoryName.substring(0, repositoryName.length() - GitRepositoryHandler.DOT_GIT.length());
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
private final GitRepositoryHandler handler;
|
||||
|
||||
Reference in New Issue
Block a user