Harmonize repository resolution

This commit is contained in:
René Pfeuffer
2018-11-27 15:31:57 +01:00
parent bc629ec648
commit d4db39755f
31 changed files with 52 additions and 69 deletions

View File

@@ -121,7 +121,7 @@ public class GitGcTask implements Runnable {
}
private void gc(Repository repository){
File file = repositoryHandler.getDirectory(repository);
File file = repositoryHandler.getDirectory(repository.getId());
Git git = null;
try {
git = open(file);

View File

@@ -119,7 +119,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
Git git = Git.wrap(open());
GitUtil.fetch(git, handler.getDirectory(remoteRepository), remoteRepository);
GitUtil.fetch(git, handler.getDirectory(remoteRepository.getId()), remoteRepository);
ObjectId localId = getDefaultBranch(git.getRepository());
ObjectId remoteId = null;

View File

@@ -196,7 +196,7 @@ public abstract class AbstractGitPushOrPullCommand extends AbstractGitCommand
*/
protected String getRemoteUrl(sonia.scm.repository.Repository repository)
{
return getRemoteUrl(handler.getDirectory(repository));
return getRemoteUrl(handler.getDirectory(repository.getId()));
}
//~--- methods --------------------------------------------------------------

View File

@@ -196,12 +196,12 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
private PullResponse pullFromScmRepository(Repository sourceRepository)
throws IOException
{
File sourceDirectory = handler.getDirectory(sourceRepository);
File sourceDirectory = handler.getDirectory(sourceRepository.getId());
Preconditions.checkArgument(sourceDirectory.exists(),
"source repository directory does not exists");
File targetDirectory = handler.getDirectory(repository);
File targetDirectory = handler.getDirectory(repository.getId());
Preconditions.checkArgument(sourceDirectory.exists(),
"target repository directory does not exists");

View File

@@ -73,7 +73,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
public GitRepositoryServiceProvider(GitRepositoryHandler handler, Repository repository) {
this.handler = handler;
this.repository = repository;
this.context = new GitContext(handler.getDirectory(repository), repository);
this.context = new GitContext(handler.getDirectory(repository.getId()), repository);
}
//~--- methods --------------------------------------------------------------

View File

@@ -106,7 +106,7 @@ public class GitRepositoryResolver implements RepositoryResolver<HttpServletRequ
if (config.isValid())
{
File gitdir = handler.getDirectory(repo);
File gitdir = handler.getDirectory(repo.getId());
if (gitdir == null) {
throw new RepositoryNotFoundException(repositoryName);
}

View File

@@ -111,7 +111,7 @@ public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
repositoryHandler.setConfig(config);
initRepository();
File path = repositoryHandler.getDirectory(repository);
File path = repositoryHandler.getDirectory(repository.getId());
assertEquals(repoPath.toString() + File.separator + AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
}
}

View File

@@ -92,9 +92,9 @@ public class AbstractRemoteCommandTestBase
outgoing = Git.init().setDirectory(outgoingDirectory).setBare(false).call();
handler = mock(GitRepositoryHandler.class);
when(handler.getDirectory(incomingRepository)).thenReturn(
when(handler.getDirectory(incomingRepository.getId())).thenReturn(
incomingDirectory);
when(handler.getDirectory(outgoingRepository)).thenReturn(
when(handler.getDirectory(outgoingRepository.getId())).thenReturn(
outgoingDirectory);
}