@Test void testMultipleTypeMirror() { metaRepo.commit(Revision.HEAD, 0, Author.SYSTEM, "", Change.ofJsonUpsert( PATH_MIRRORS, "[{" + " \"enabled\": true," + " \"type\": \"multiple\"," + " \"defaultDirection\": \"LOCAL_TO_REMOTE\"," + " \"defaultLocalPath\": \"/source\"," + " \"includes\": [{" + " \"pattern\": \"^([^.]+)(\\\\.[^.]+)$\"," + " \"replacement\": \"git+ssh: " }]," + " \"excludes\": [ \"^qux\\\\.net$\" ]" + "}, {" + " \"type\": \"multiple\"," + " \"defaultDirection\": \"LOCAL_TO_REMOTE\"," + " \"defaultLocalPath\": \"/source\"," + " \"defaultSchedule\": \"* * * * * ?\"," + " \"includes\": [{" + " \"pattern\": \"^qux\\\\.net$\"," + " \"replacement\": \"dogma: " \"schedule\": \"0 0 * * * ?\"," + " \"direction\": \"REMOTE_TO_LOCAL\"," + " \"localPath\": \"/mirrored/qux\"" + " }]" + "}, {" + " \"enabled\": false," + " \"type\": \"multiple\"," + " \"defaultDirection\": \"REMOTE_TO_LOCAL\"," + " \"defaultLocalPath\": \"/otherSource\"," + " \"includes\": [{" + " \"pattern\": \"^([^.]+)(\\\\.[^.]+)$\"," + " \"replacement\": \"git+ssh: " }]" + "}]"), UPSERT_CREDENTIALS).join(); assertThat(metaRepo.mirrors()).isEmpty(); project.repos().create("foo.com", Author.SYSTEM); project.repos().create("bar.org", Author.SYSTEM); project.repos().create("qux.net", Author.SYSTEM); final List<Mirror> mirrors = findMirrors(); assertThat(mirrors.stream() .map(m -> m.localRepo().name()) .collect(Collectors.toList())).containsExactly("bar.org", "foo.com", "qux.net"); final Mirror foo = mirrors.get(1); final Mirror bar = mirrors.get(0); final Mirror qux = mirrors.get(2); assertThat(foo.direction()).isEqualTo(MirrorDirection.LOCAL_TO_REMOTE); assertThat(bar.direction()).isEqualTo(MirrorDirection.LOCAL_TO_REMOTE); assertThat(qux.direction()).isEqualTo(MirrorDirection.REMOTE_TO_LOCAL); assertThat(foo.schedule().equivalent(cronParser.parse("0 * * * * ?"))).isTrue(); assertThat(bar.schedule().equivalent(cronParser.parse("0 * * * * ?"))).isTrue(); assertThat(qux.schedule().equivalent(cronParser.parse("0 0 * * * ?"))).isTrue(); assertThat(foo.localPath()).isEqualTo("/source/"); assertThat(bar.localPath()).isEqualTo("/source/"); assertThat(qux.localPath()).isEqualTo("/mirrored/qux/"); assertThat(foo.remoteRepoUri().toASCIIString()).isEqualTo("git+ssh: assertThat(bar.remoteRepoUri().toASCIIString()).isEqualTo("git+ssh: assertThat(qux.remoteRepoUri().toASCIIString()).isEqualTo("dogma: assertThat(foo.remotePath()).isEqualTo("/"); assertThat(bar.remotePath()).isEqualTo("/"); assertThat(qux.remotePath()).isEqualTo("/some-path/"); assertThat(foo.remoteBranch()).isEqualTo("develop-foo"); assertThat(bar.remoteBranch()).isEqualTo("develop-bar"); assertThat(qux.remoteBranch()).isNull(); assertThat(foo.direction()).isEqualTo(MirrorDirection.LOCAL_TO_REMOTE); assertThat(bar.direction()).isEqualTo(MirrorDirection.LOCAL_TO_REMOTE); assertThat(qux.direction()).isEqualTo(MirrorDirection.REMOTE_TO_LOCAL); }
@Override public Set<Mirror> mirrors() { mirrorLock.lock(); try { final int headRev = normalizeNow(Revision.HEAD).major(); final Set<String> repos = parent().repos().list().keySet(); if (headRev > mirrorRev || !mirrorRepos.equals(repos)) { mirrors = loadMirrors(headRev); mirrorRev = headRev; mirrorRepos = repos; } return mirrors; } finally { mirrorLock.unlock(); } }
DefaultMetaRepository extends RepositoryWrapper implements MetaRepository { @Override public Set<Mirror> mirrors() { mirrorLock.lock(); try { final int headRev = normalizeNow(Revision.HEAD).major(); final Set<String> repos = parent().repos().list().keySet(); if (headRev > mirrorRev || !mirrorRepos.equals(repos)) { mirrors = loadMirrors(headRev); mirrorRev = headRev; mirrorRepos = repos; } return mirrors; } finally { mirrorLock.unlock(); } } }
DefaultMetaRepository extends RepositoryWrapper implements MetaRepository { @Override public Set<Mirror> mirrors() { mirrorLock.lock(); try { final int headRev = normalizeNow(Revision.HEAD).major(); final Set<String> repos = parent().repos().list().keySet(); if (headRev > mirrorRev || !mirrorRepos.equals(repos)) { mirrors = loadMirrors(headRev); mirrorRev = headRev; mirrorRepos = repos; } return mirrors; } finally { mirrorLock.unlock(); } } DefaultMetaRepository(Repository repo); }
DefaultMetaRepository extends RepositoryWrapper implements MetaRepository { @Override public Set<Mirror> mirrors() { mirrorLock.lock(); try { final int headRev = normalizeNow(Revision.HEAD).major(); final Set<String> repos = parent().repos().list().keySet(); if (headRev > mirrorRev || !mirrorRepos.equals(repos)) { mirrors = loadMirrors(headRev); mirrorRev = headRev; mirrorRepos = repos; } return mirrors; } finally { mirrorLock.unlock(); } } DefaultMetaRepository(Repository repo); @Override Set<Mirror> mirrors(); }
DefaultMetaRepository extends RepositoryWrapper implements MetaRepository { @Override public Set<Mirror> mirrors() { mirrorLock.lock(); try { final int headRev = normalizeNow(Revision.HEAD).major(); final Set<String> repos = parent().repos().list().keySet(); if (headRev > mirrorRev || !mirrorRepos.equals(repos)) { mirrors = loadMirrors(headRev); mirrorRev = headRev; mirrorRepos = repos; } return mirrors; } finally { mirrorLock.unlock(); } } DefaultMetaRepository(Repository repo); @Override Set<Mirror> mirrors();  }