mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
Merge with 2.0.0-m3
This commit is contained in:
14
pom.xml
14
pom.xml
@@ -409,8 +409,9 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.sdorra</groupId>
|
<groupId>com.github.sdorra</groupId>
|
||||||
<artifactId>buildfrontend-maven-plugin</artifactId>
|
<artifactId>buildfrontend-maven-plugin</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
@@ -432,6 +433,12 @@
|
|||||||
<artifactId>enunciate-maven-plugin</artifactId>
|
<artifactId>enunciate-maven-plugin</artifactId>
|
||||||
<version>${enunciate.version}</version>
|
<version>${enunciate.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>sonia.scm.maven</groupId>
|
||||||
|
<artifactId>smp-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0-alpha-4</version>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|
||||||
@@ -838,8 +845,8 @@
|
|||||||
<quartz.version>2.2.3</quartz.version>
|
<quartz.version>2.2.3</quartz.version>
|
||||||
|
|
||||||
<!-- frontend -->
|
<!-- frontend -->
|
||||||
<nodejs.version>8.11.4</nodejs.version>
|
<nodejs.version>10.16.0</nodejs.version>
|
||||||
<yarn.version>1.9.4</yarn.version>
|
<yarn.version>1.16.0</yarn.version>
|
||||||
|
|
||||||
<!-- build properties -->
|
<!-- build properties -->
|
||||||
<project.build.javaLevel>1.8</project.build.javaLevel>
|
<project.build.javaLevel>1.8</project.build.javaLevel>
|
||||||
@@ -855,7 +862,6 @@
|
|||||||
<!-- *UserPassword JS files are excluded because extraction of common code would not make the code more readable -->
|
<!-- *UserPassword JS files are excluded because extraction of common code would not make the code more readable -->
|
||||||
<sonar.cpd.exclusions>**/*StoreFactory.java,**/*UserPassword.js</sonar.cpd.exclusions>
|
<sonar.cpd.exclusions>**/*StoreFactory.java,**/*UserPassword.js</sonar.cpd.exclusions>
|
||||||
|
|
||||||
<node.version>8.11.4</node.version>
|
|
||||||
<sonar.nodejs.executable>./scm-ui/target/frontend/buildfrontend-node/node-v${node.version}-linux-x64/bin/node</sonar.nodejs.executable>
|
<sonar.nodejs.executable>./scm-ui/target/frontend/buildfrontend-node/node-v${node.version}-linux-x64/bin/node</sonar.nodejs.executable>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -166,4 +166,8 @@ public class PathBasedRepositoryLocationResolver extends BasicRepositoryLocation
|
|||||||
pathById.put(repositoryId, repositoryBasePath);
|
pathById.put(repositoryId, repositoryBasePath);
|
||||||
writePathDatabase();
|
writePathDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
this.read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,4 +198,11 @@ public class XmlRepositoryDAO implements RepositoryDAO {
|
|||||||
public Long getLastModified() {
|
public Long getLastModified() {
|
||||||
return repositoryLocationResolver.getLastModified();
|
return repositoryLocationResolver.getLastModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
repositoryLocationResolver.refresh();
|
||||||
|
byNamespaceAndName.clear();
|
||||||
|
byId.clear();
|
||||||
|
init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import org.junit.jupiter.api.Nested;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junitpioneer.jupiter.TempDirectory;
|
import org.junitpioneer.jupiter.TempDirectory;
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.Captor;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
@@ -33,7 +31,9 @@ import static java.util.Arrays.asList;
|
|||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -48,9 +48,6 @@ class XmlRepositoryDAOTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private PathBasedRepositoryLocationResolver locationResolver;
|
private PathBasedRepositoryLocationResolver locationResolver;
|
||||||
|
|
||||||
@Captor
|
|
||||||
private ArgumentCaptor<BiConsumer<String, Path>> forAllCaptor;
|
|
||||||
|
|
||||||
private FileSystem fileSystem = new DefaultFileSystem();
|
private FileSystem fileSystem = new DefaultFileSystem();
|
||||||
|
|
||||||
private XmlRepositoryDAO dao;
|
private XmlRepositoryDAO dao;
|
||||||
@@ -285,43 +282,80 @@ class XmlRepositoryDAOTest {
|
|||||||
|
|
||||||
verify(locationResolver).updateModificationDate();
|
verify(locationResolver).updateModificationDate();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
private String getXmlFileContent(String id) {
|
||||||
void shouldReadExistingRepositoriesFromPathDatabase(@TempDirectory.TempDir Path basePath) throws IOException {
|
Path storePath = metadataFile(id);
|
||||||
doNothing().when(locationResolver).forAllPaths(forAllCaptor.capture());
|
|
||||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(locationResolver, fileSystem);
|
|
||||||
|
|
||||||
Path repositoryPath = basePath.resolve("existing");
|
assertThat(storePath).isRegularFile();
|
||||||
Files.createDirectories(repositoryPath);
|
return content(storePath);
|
||||||
URL metadataUrl = Resources.getResource("sonia/scm/store/repositoryDaoMetadata.xml");
|
}
|
||||||
Files.copy(metadataUrl.openStream(), repositoryPath.resolve("metadata.xml"));
|
|
||||||
|
|
||||||
forAllCaptor.getValue().accept("existing", repositoryPath);
|
private Path metadataFile(String id) {
|
||||||
|
return locationResolver.create(id).resolve("metadata.xml");
|
||||||
|
}
|
||||||
|
|
||||||
assertThat(dao.contains(new NamespaceAndName("space", "existing"))).isTrue();
|
private String content(Path storePath) {
|
||||||
}
|
try {
|
||||||
|
return new String(Files.readAllBytes(storePath), Charsets.UTF_8);
|
||||||
private String getXmlFileContent(String id) {
|
} catch (IOException e) {
|
||||||
Path storePath = metadataFile(id);
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
assertThat(storePath).isRegularFile();
|
|
||||||
return content(storePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Path metadataFile(String id) {
|
|
||||||
return locationResolver.create(id).resolve("metadata.xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String content(Path storePath) {
|
|
||||||
try {
|
|
||||||
return new String(Files.readAllBytes(storePath), Charsets.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Repository createRepository(String id) {
|
@Nested
|
||||||
|
class WithExistingRepositories {
|
||||||
|
|
||||||
|
private Path repositoryPath;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void createMetadataFileForRepository(@TempDirectory.TempDir Path basePath) throws IOException {
|
||||||
|
repositoryPath = basePath.resolve("existing");
|
||||||
|
|
||||||
|
Files.createDirectories(repositoryPath);
|
||||||
|
URL metadataUrl = Resources.getResource("sonia/scm/store/repositoryDaoMetadata.xml");
|
||||||
|
Files.copy(metadataUrl.openStream(), repositoryPath.resolve("metadata.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReadExistingRepositoriesFromPathDatabase() {
|
||||||
|
// given
|
||||||
|
mockExistingPath();
|
||||||
|
|
||||||
|
// when
|
||||||
|
XmlRepositoryDAO dao = new XmlRepositoryDAO(locationResolver, fileSystem);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(dao.contains(new NamespaceAndName("space", "existing"))).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRefreshWithExistingRepositoriesFromPathDatabase() {
|
||||||
|
// given
|
||||||
|
doNothing().when(locationResolver).forAllPaths(any());
|
||||||
|
XmlRepositoryDAO dao = new XmlRepositoryDAO(locationResolver, fileSystem);
|
||||||
|
|
||||||
|
mockExistingPath();
|
||||||
|
|
||||||
|
// when
|
||||||
|
dao.refresh();
|
||||||
|
|
||||||
|
// then
|
||||||
|
verify(locationResolver).refresh();
|
||||||
|
assertThat(dao.contains(new NamespaceAndName("space", "existing"))).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mockExistingPath() {
|
||||||
|
doAnswer(
|
||||||
|
invocation -> {
|
||||||
|
((BiConsumer<String, Path>) invocation.getArgument(0)).accept("existing", repositoryPath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
).when(locationResolver).forAllPaths(any());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Repository createRepository(String id) {
|
||||||
return new Repository(id, "xml", "space", id);
|
return new Repository(id, "xml", "space", id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,6 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>sonia.scm.maven</groupId>
|
<groupId>sonia.scm.maven</groupId>
|
||||||
<artifactId>smp-maven-plugin</artifactId>
|
<artifactId>smp-maven-plugin</artifactId>
|
||||||
<version>1.0.0-alpha-3</version>
|
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,6 @@
|
|||||||
"@scm-manager/ui-extensions": "^0.1.2"
|
"@scm-manager/ui-extensions": "^0.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.28"
|
"@scm-manager/ui-bundler": "^0.0.29"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010, Sebastian Sdorra
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from this
|
|
||||||
* software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* http://bitbucket.org/sdorra/scm-manager
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.web.lfs;
|
|
||||||
|
|
||||||
import com.github.legman.Subscribe;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import sonia.scm.EagerSingleton;
|
|
||||||
import sonia.scm.HandlerEventType;
|
|
||||||
import sonia.scm.plugin.Extension;
|
|
||||||
import sonia.scm.repository.GitRepositoryHandler;
|
|
||||||
import sonia.scm.repository.Repository;
|
|
||||||
import sonia.scm.repository.RepositoryEvent;
|
|
||||||
import sonia.scm.store.Blob;
|
|
||||||
import sonia.scm.store.BlobStore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Listener which removes all lfs objects from a blob store, whenever its corresponding git repository gets deleted.
|
|
||||||
*
|
|
||||||
* @author Sebastian Sdorra
|
|
||||||
* @since 1.54
|
|
||||||
*/
|
|
||||||
@Extension
|
|
||||||
@EagerSingleton
|
|
||||||
public class LfsStoreRemoveListener {
|
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(LfsBlobStoreFactory.class);
|
|
||||||
|
|
||||||
private final LfsBlobStoreFactory lfsBlobStoreFactory;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public LfsStoreRemoveListener(LfsBlobStoreFactory lfsBlobStoreFactory) {
|
|
||||||
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove all object from the blob store, if the event is an delete event and the repository is a git repository.
|
|
||||||
*
|
|
||||||
* @param event repository event
|
|
||||||
*/
|
|
||||||
@Subscribe
|
|
||||||
public void handleRepositoryEvent(RepositoryEvent event) {
|
|
||||||
if ( isDeleteEvent(event) && isGitRepositoryEvent(event) ) {
|
|
||||||
removeLfsStore(event.getItem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDeleteEvent(RepositoryEvent event) {
|
|
||||||
return HandlerEventType.DELETE == event.getEventType();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isGitRepositoryEvent(RepositoryEvent event) {
|
|
||||||
return event.getItem() != null
|
|
||||||
&& event.getItem().getType().equals(GitRepositoryHandler.TYPE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeLfsStore(Repository repository) {
|
|
||||||
LOG.debug("remove all blobs from store, because corresponding git repository {} was removed", repository.getName());
|
|
||||||
BlobStore blobStore = lfsBlobStoreFactory.getLfsBlobStore(repository);
|
|
||||||
for ( Blob blob : blobStore.getAll() ) {
|
|
||||||
LOG.trace("remove blob {}, because repository {} was removed", blob.getId(), repository.getName());
|
|
||||||
blobStore.remove(blob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2010, Sebastian Sdorra
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from this
|
|
||||||
* software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* http://bitbucket.org/sdorra/scm-manager
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.web.lfs;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.List;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.InjectMocks;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
|
||||||
import sonia.scm.HandlerEventType;
|
|
||||||
import sonia.scm.repository.Repository;
|
|
||||||
import sonia.scm.repository.RepositoryEvent;
|
|
||||||
import sonia.scm.repository.RepositoryTestData;
|
|
||||||
import sonia.scm.store.Blob;
|
|
||||||
import sonia.scm.store.BlobStore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit tests for {@link LfsStoreRemoveListener}.
|
|
||||||
*
|
|
||||||
* @author Sebastian Sdorra
|
|
||||||
*/
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class LfsStoreRemoveListenerTest {
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private LfsBlobStoreFactory lfsBlobStoreFactory;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private BlobStore blobStore;
|
|
||||||
|
|
||||||
@InjectMocks
|
|
||||||
private LfsStoreRemoveListener lfsStoreRemoveListener;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHandleRepositoryEventWithNonDeleteEvents() {
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.BEFORE_CREATE));
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.CREATE));
|
|
||||||
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.BEFORE_MODIFY));
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.MODIFY));
|
|
||||||
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.BEFORE_DELETE));
|
|
||||||
|
|
||||||
verifyZeroInteractions(lfsBlobStoreFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHandleRepositoryEventWithNonGitRepositories() {
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.DELETE, "svn"));
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.DELETE, "hg"));
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(event(HandlerEventType.DELETE, "dummy"));
|
|
||||||
|
|
||||||
verifyZeroInteractions(lfsBlobStoreFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHandleRepositoryEvent() {
|
|
||||||
Repository heartOfGold = RepositoryTestData.createHeartOfGold("git");
|
|
||||||
|
|
||||||
when(lfsBlobStoreFactory.getLfsBlobStore(heartOfGold)).thenReturn(blobStore);
|
|
||||||
Blob blobA = mockBlob("a");
|
|
||||||
Blob blobB = mockBlob("b");
|
|
||||||
List<Blob> blobs = Lists.newArrayList(blobA, blobB);
|
|
||||||
when(blobStore.getAll()).thenReturn(blobs);
|
|
||||||
|
|
||||||
|
|
||||||
lfsStoreRemoveListener.handleRepositoryEvent(new RepositoryEvent(HandlerEventType.DELETE, heartOfGold));
|
|
||||||
verify(blobStore).getAll();
|
|
||||||
verify(blobStore).remove(blobA);
|
|
||||||
verify(blobStore).remove(blobB);
|
|
||||||
|
|
||||||
verifyNoMoreInteractions(blobStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Blob mockBlob(String id) {
|
|
||||||
Blob blob = mock(Blob.class);
|
|
||||||
when(blob.getId()).thenReturn(id);
|
|
||||||
return blob;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RepositoryEvent event(HandlerEventType eventType) {
|
|
||||||
return event(eventType, "git");
|
|
||||||
}
|
|
||||||
|
|
||||||
private RepositoryEvent event(HandlerEventType eventType, String repositoryType) {
|
|
||||||
return new RepositoryEvent(eventType, RepositoryTestData.create42Puzzle(repositoryType));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@scm-manager/scm-hg-plugin",
|
"name": "@scm-manager/scm-hg-plugin",
|
||||||
"main": "src/main/js/index.js",
|
"main": "src/main/js/index.js",
|
||||||
"license" : "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ui-bundler plugin"
|
"build": "ui-bundler plugin"
|
||||||
},
|
},
|
||||||
@@ -9,6 +9,6 @@
|
|||||||
"@scm-manager/ui-extensions": "^0.1.2"
|
"@scm-manager/ui-extensions": "^0.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.28"
|
"@scm-manager/ui-bundler": "^0.0.29"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,6 @@
|
|||||||
"@scm-manager/ui-extensions": "^0.1.2"
|
"@scm-manager/ui-extensions": "^0.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.28"
|
"@scm-manager/ui-bundler": "^0.0.29"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
|||||||
"eslint-fix": "eslint src --fix"
|
"eslint-fix": "eslint src --fix"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.28",
|
"@scm-manager/ui-bundler": "^0.0.29",
|
||||||
"create-index": "^2.3.0",
|
"create-index": "^2.3.0",
|
||||||
"enzyme": "^3.5.0",
|
"enzyme": "^3.5.0",
|
||||||
"enzyme-adapter-react-16": "^1.3.1",
|
"enzyme-adapter-react-16": "^1.3.1",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
|||||||
"check": "flow check"
|
"check": "flow check"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.28"
|
"@scm-manager/ui-bundler": "^0.0.29"
|
||||||
},
|
},
|
||||||
"browserify": {
|
"browserify": {
|
||||||
"transform": [
|
"transform": [
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -54,7 +54,7 @@
|
|||||||
"pre-commit": "jest && flow && eslint src"
|
"pre-commit": "jest && flow && eslint src"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scm-manager/ui-bundler": "^0.0.28",
|
"@scm-manager/ui-bundler": "^0.0.29",
|
||||||
"concat": "^1.0.3",
|
"concat": "^1.0.3",
|
||||||
"copyfiles": "^2.0.0",
|
"copyfiles": "^2.0.0",
|
||||||
"enzyme": "^3.3.0",
|
"enzyme": "^3.3.0",
|
||||||
|
|||||||
1022
scm-ui/yarn.lock
1022
scm-ui/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -461,7 +461,6 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>sonia.scm.maven</groupId>
|
<groupId>sonia.scm.maven</groupId>
|
||||||
<artifactId>smp-maven-plugin</artifactId>
|
<artifactId>smp-maven-plugin</artifactId>
|
||||||
<version>1.0.0-alpha-2</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<artifactItems>
|
<artifactItems>
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import sonia.scm.SCMContextProvider;
|
|||||||
import sonia.scm.migration.UpdateStep;
|
import sonia.scm.migration.UpdateStep;
|
||||||
import sonia.scm.plugin.Extension;
|
import sonia.scm.plugin.Extension;
|
||||||
import sonia.scm.repository.xml.PathBasedRepositoryLocationResolver;
|
import sonia.scm.repository.xml.PathBasedRepositoryLocationResolver;
|
||||||
|
import sonia.scm.repository.xml.XmlRepositoryDAO;
|
||||||
import sonia.scm.store.StoreConstants;
|
import sonia.scm.store.StoreConstants;
|
||||||
import sonia.scm.version.Version;
|
import sonia.scm.version.Version;
|
||||||
|
|
||||||
@@ -27,10 +28,12 @@ public class XmlRepositoryFileNameUpdateStep implements UpdateStep {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(XmlRepositoryFileNameUpdateStep.class);
|
private static final Logger LOG = LoggerFactory.getLogger(XmlRepositoryFileNameUpdateStep.class);
|
||||||
|
|
||||||
private final SCMContextProvider contextProvider;
|
private final SCMContextProvider contextProvider;
|
||||||
|
private final XmlRepositoryDAO repositoryDAO;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public XmlRepositoryFileNameUpdateStep(SCMContextProvider contextProvider) {
|
public XmlRepositoryFileNameUpdateStep(SCMContextProvider contextProvider, XmlRepositoryDAO repositoryDAO) {
|
||||||
this.contextProvider = contextProvider;
|
this.contextProvider = contextProvider;
|
||||||
|
this.repositoryDAO = repositoryDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,6 +44,7 @@ public class XmlRepositoryFileNameUpdateStep implements UpdateStep {
|
|||||||
if (Files.exists(oldRepositoriesFile)) {
|
if (Files.exists(oldRepositoriesFile)) {
|
||||||
LOG.info("moving old repositories database files to repository-paths file");
|
LOG.info("moving old repositories database files to repository-paths file");
|
||||||
Files.move(oldRepositoriesFile, newRepositoryPathsFile);
|
Files.move(oldRepositoriesFile, newRepositoryPathsFile);
|
||||||
|
repositoryDAO.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||||||
import org.junitpioneer.jupiter.TempDirectory;
|
import org.junitpioneer.jupiter.TempDirectory;
|
||||||
import sonia.scm.SCMContextProvider;
|
import sonia.scm.SCMContextProvider;
|
||||||
import sonia.scm.repository.xml.PathBasedRepositoryLocationResolver;
|
import sonia.scm.repository.xml.PathBasedRepositoryLocationResolver;
|
||||||
|
import sonia.scm.repository.xml.XmlRepositoryDAO;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -16,12 +16,14 @@ import java.nio.file.Path;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ExtendWith(TempDirectory.class)
|
@ExtendWith(TempDirectory.class)
|
||||||
class XmlRepositoryFileNameUpdateStepTest {
|
class XmlRepositoryFileNameUpdateStepTest {
|
||||||
|
|
||||||
SCMContextProvider contextProvider = mock(SCMContextProvider.class);
|
SCMContextProvider contextProvider = mock(SCMContextProvider.class);
|
||||||
|
XmlRepositoryDAO repositoryDAO = mock(XmlRepositoryDAO.class);
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void mockScmHome(@TempDirectory.TempDir Path tempDir) {
|
void mockScmHome(@TempDirectory.TempDir Path tempDir) {
|
||||||
@@ -29,8 +31,8 @@ class XmlRepositoryFileNameUpdateStepTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCopyRepositoriesFileToRepositoryPathsFile(@TempDirectory.TempDir Path tempDir) throws JAXBException, IOException {
|
void shouldCopyRepositoriesFileToRepositoryPathsFile(@TempDirectory.TempDir Path tempDir) throws IOException {
|
||||||
XmlRepositoryFileNameUpdateStep updateStep = new XmlRepositoryFileNameUpdateStep(contextProvider);
|
XmlRepositoryFileNameUpdateStep updateStep = new XmlRepositoryFileNameUpdateStep(contextProvider, repositoryDAO);
|
||||||
URL url = Resources.getResource("sonia/scm/update/repository/formerV2RepositoryFile.xml");
|
URL url = Resources.getResource("sonia/scm/update/repository/formerV2RepositoryFile.xml");
|
||||||
Path configDir = tempDir.resolve("config");
|
Path configDir = tempDir.resolve("config");
|
||||||
Files.createDirectories(configDir);
|
Files.createDirectories(configDir);
|
||||||
@@ -40,5 +42,6 @@ class XmlRepositoryFileNameUpdateStepTest {
|
|||||||
|
|
||||||
assertThat(configDir.resolve(PathBasedRepositoryLocationResolver.STORE_NAME + ".xml")).exists();
|
assertThat(configDir.resolve(PathBasedRepositoryLocationResolver.STORE_NAME + ".xml")).exists();
|
||||||
assertThat(configDir.resolve("repositories.xml")).doesNotExist();
|
assertThat(configDir.resolve("repositories.xml")).doesNotExist();
|
||||||
|
verify(repositoryDAO).refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user