mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Remove dead code
This commit is contained in:
@@ -86,7 +86,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends RepositoryConfig
|
||||
|
||||
@Override
|
||||
public Repository create(Repository repository) {
|
||||
File directory = repositoryLocationResolver.getNativeDirectory(repository);
|
||||
File directory = initialRepositoryLocationResolver.getDefaultNativeDirectory(repository);
|
||||
if (directory != null && directory.exists()) {
|
||||
throw new AlreadyExistsException(repository);
|
||||
}
|
||||
@@ -161,11 +161,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends RepositoryConfig
|
||||
return directory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getInitialBaseDirectory() {
|
||||
return initialRepositoryLocationResolver.getBaseDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionInformation() {
|
||||
return DEFAULT_VERSION_INFORMATION;
|
||||
|
||||
@@ -30,15 +30,16 @@ public class InitialRepositoryLocationResolver {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
File getBaseDirectory() {
|
||||
return new File(context.getBaseDirectory(), DEFAULT_REPOSITORY_PATH);
|
||||
}
|
||||
|
||||
File getDefaultDirectory(Repository repository) {
|
||||
String initialRepoFolder = getRelativeRepositoryPath(repository);
|
||||
return new File(context.getBaseDirectory(), initialRepoFolder);
|
||||
}
|
||||
|
||||
File getDefaultNativeDirectory(Repository repository) {
|
||||
String initialRepoFolder = getRelativeRepositoryPath(repository);
|
||||
return new File(context.getBaseDirectory(), initialRepoFolder + "/data");
|
||||
}
|
||||
|
||||
public String getRelativeRepositoryPath(Repository repository) {
|
||||
return DEFAULT_REPOSITORY_PATH + File.separator + repository.getId();
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ import java.nio.file.Path;
|
||||
public interface PathBasedRepositoryDAO extends RepositoryDAO {
|
||||
|
||||
/**
|
||||
* get the current path of the repository or create it
|
||||
*
|
||||
* @param repository
|
||||
* @return the current path of the repository
|
||||
* Get the current path of the repository. This works for existing repositories only, not for repositories that should be created.
|
||||
*/
|
||||
Path getPath(Repository repository) ;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,4 @@ public interface RepositoryDirectoryHandler extends RepositoryHandler {
|
||||
* @return the current directory of the given repository
|
||||
*/
|
||||
File getDirectory(Repository repository);
|
||||
|
||||
/**
|
||||
* get the initial directory of all repositories
|
||||
* @return the initial directory of all repositories
|
||||
*/
|
||||
File getInitialBaseDirectory();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,10 @@ public class XmlRepositoryDAO
|
||||
return context
|
||||
.getBaseDirectory()
|
||||
.toPath()
|
||||
.resolve(findExistingRepositoryPath(repository).map(RepositoryPath::getPath).orElse(initialRepositoryLocationResolver.getRelativeRepositoryPath(repository)));
|
||||
.resolve(
|
||||
findExistingRepositoryPath(repository)
|
||||
.map(RepositoryPath::getPath)
|
||||
.orElseThrow(() -> new InternalRepositoryException(repository, "could not find base directory for repository")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -104,19 +104,6 @@ public class XmlRepositoryDAOTest {
|
||||
assertThat(path.toString()).isEqualTo("/tmp/path");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetPathForNewRepository() {
|
||||
when(db.getPaths()).thenReturn(emptyList());
|
||||
|
||||
InitialRepositoryLocationResolver initialRepositoryLocationResolver = new InitialRepositoryLocationResolver(context);
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, initialRepositoryLocationResolver, context);
|
||||
|
||||
Repository newRepository = new Repository("id", "new", null, null);
|
||||
Path path = dao.getPath(newRepository);
|
||||
|
||||
assertThat(path.toString()).isEqualTo(context.getBaseDirectory().getPath() + "/" + InitialRepositoryLocationResolver.DEFAULT_REPOSITORY_PATH + "/id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindRepositoryForRelativePath() {
|
||||
new File(context.getBaseDirectory(), "relative/path/data").mkdirs();
|
||||
|
||||
@@ -33,10 +33,6 @@ public class HgHookCallbackServletTest {
|
||||
String path = "/tmp/hg/12345";
|
||||
when(request.getParameter(PARAM_REPOSITORYPATH)).thenReturn(path);
|
||||
|
||||
|
||||
File file = new File(path);
|
||||
when(handler.getInitialBaseDirectory()).thenReturn(file);
|
||||
|
||||
servlet.doPost(request, response);
|
||||
|
||||
verify(response, never()).sendError(anyInt());
|
||||
|
||||
Reference in New Issue
Block a user