@Test void testMultipleTypeMirrorWithCredentialId() { metaRepo.commit(Revision.HEAD, 0, Author.SYSTEM, "", Change.ofJsonUpsert( PATH_MIRRORS, "[{" + " \"type\": \"multiple\"," + " \"defaultDirection\": \"REMOTE_TO_LOCAL\"," + " \"includes\": [{" + " \"pattern\": \"^(foo|bar)$\"," + " \"replacement\": \"git+ssh: " \"credentialId\": \"alice\"" + " }]" + "}, {" + " \"type\": \"multiple\"," + " \"defaultDirection\": \"REMOTE_TO_LOCAL\"," + " \"defaultCredentialId\": \"alice\"," + " \"includes\": [{" + " \"pattern\": \"^(qux)$\"," + " \"replacement\": \"git+ssh: " }]" + "}]"), UPSERT_CREDENTIALS).join(); assertThat(metaRepo.mirrors()).isEmpty(); project.repos().create("foo", Author.SYSTEM); project.repos().create("bar", Author.SYSTEM); project.repos().create("qux", Author.SYSTEM); final List<Mirror> mirrors = findMirrors(); assertThat(mirrors.stream() .map(m -> m.localRepo().name()) .collect(Collectors.toList())).containsExactly("bar", "foo", "qux"); final MirrorCredential fooCredential = mirrors.get(1).credential(); assertThat(fooCredential).isInstanceOf(PasswordMirrorCredential.class); assertThat(((PasswordMirrorCredential) fooCredential).username()).isEqualTo("alice"); assertThat(mirrors.get(0).credential()).isSameAs(fooCredential); assertThat(mirrors.get(2).credential()).isSameAs(fooCredential); }
@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();  }