mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-10-31 10:35:56 +01:00 
			
		
		
		
	Fix SVN repo mirror update (#1745)
Initialize svn repository on mirror update if first initialization failed.
This commit is contained in:
		| @@ -85,7 +85,7 @@ public class SvnMirrorCommand extends AbstractSvnCommand implements MirrorComman | ||||
|       SVNURL url = createUrlForLocalRepository(); | ||||
|       SVNAdminClient admin = createAdminClient(url, mirrorCommandRequest); | ||||
|  | ||||
|       consumer.accept(admin); | ||||
|       handleConsumer(mirrorCommandRequest, consumer, url, admin); | ||||
|       afterUpdate = context.open().getLatestRevision(); | ||||
|     } catch (SVNException e) { | ||||
|       LOG.info("Could not mirror svn repository", e); | ||||
| @@ -104,6 +104,19 @@ public class SvnMirrorCommand extends AbstractSvnCommand implements MirrorComman | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   private void handleConsumer(MirrorCommandRequest mirrorCommandRequest, AdminConsumer consumer, SVNURL url, SVNAdminClient admin) throws SVNException { | ||||
|     try { | ||||
|       consumer.accept(admin); | ||||
|     } catch (SVNException e) { | ||||
|       if (e.getMessage().equals("svn: E204899: Destination repository has not been initialized")) { | ||||
|         SVNURL source = SVNURL.parseURIEncoded(mirrorCommandRequest.getSourceUrl()); | ||||
|         admin.doCompleteSynchronize(source, url); | ||||
|       } else { | ||||
|         throw e; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   private SVNURL createUrlForLocalRepository() { | ||||
|     try { | ||||
|       return SVNURL.fromFile(context.getDirectory()); | ||||
|   | ||||
| @@ -82,6 +82,14 @@ public class SvnMirrorCommandTest extends AbstractSvnCommandTestBase { | ||||
|     assertThat(result.getLog()).contains("Updated from revision 0 to revision 5"); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void shouldDoMirrorUpdateOnNotInitializedRepo() { | ||||
|     MirrorCommandResult result = callMirrorUpdate(emptyContext, repositoryDirectory); | ||||
|  | ||||
|     assertThat(result.getResult()).isEqualTo(OK); | ||||
|     assertThat(result.getLog()).contains("Updated from revision 0 to revision 5"); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void shouldUseCredentials() { | ||||
|     MirrorCommandResult result = callMirror(emptyContext, repositoryDirectory, createCredential("svnadmin", "secret")); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user