This commit is contained in:
Mohamed Karray
2018-11-15 11:28:33 +01:00
381 changed files with 12331 additions and 11177 deletions

View File

@@ -1,125 +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.api.rest.resources;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Singleton;
import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.SvnConfig;
import sonia.scm.repository.SvnRepositoryHandler;
//~--- JDK imports ------------------------------------------------------------
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
/**
*
* @author Sebastian Sdorra
*/
@Singleton
@Path("config/repositories/svn")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public class SvnConfigResource
{
/**
* Constructs ...
*
*
* @param repositoryManager
*/
@Inject
public SvnConfigResource(RepositoryManager repositoryManager)
{
repositoryHandler = (SvnRepositoryHandler) repositoryManager.getHandler(
SvnRepositoryHandler.TYPE_NAME);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@GET
public SvnConfig getConfig()
{
SvnConfig config = repositoryHandler.getConfig();
if (config == null)
{
config = new SvnConfig();
repositoryHandler.setConfig(config);
}
return config;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param uriInfo
* @param config
*
* @return
*/
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response setConfig(@Context UriInfo uriInfo, SvnConfig config)
{
repositoryHandler.setConfig(config);
repositoryHandler.storeConfig();
return Response.created(uriInfo.getRequestUri()).build();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private SvnRepositoryHandler repositoryHandler;
}

View File

@@ -56,6 +56,8 @@ import sonia.scm.util.Util;
import java.io.File;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
//~--- JDK imports ------------------------------------------------------------
/**
@@ -173,7 +175,8 @@ public class SvnRepositoryHandler
}
catch (SVNException ex)
{
throw new InternalRepositoryException(ex);
logger.error("could not create svn repository", ex);
throw new InternalRepositoryException(entity(repository), "could not create repository", ex);
}
finally
{

View File

@@ -59,6 +59,9 @@ import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
import static sonia.scm.NotFoundException.notFound;
//~--- JDK imports ------------------------------------------------------------
/**
@@ -102,7 +105,7 @@ public final class SvnUtil
//~--- methods --------------------------------------------------------------
public static long parseRevision(String v) throws RevisionNotFoundException {
public static long parseRevision(String v, Repository repository) {
long result = -1l;
if (!Strings.isNullOrEmpty(v))
@@ -113,7 +116,7 @@ public final class SvnUtil
}
catch (NumberFormatException ex)
{
throw new RevisionNotFoundException(v);
throw notFound(entity("Revision", v).in(repository));
}
}
@@ -339,7 +342,7 @@ public final class SvnUtil
}
}
public static long getRevisionNumber(String revision) throws RevisionNotFoundException {
public static long getRevisionNumber(String revision, Repository repository) {
// REVIEW Bei SVN wird ohne Revision die -1 genommen, was zu einem Fehler führt
long revisionNumber = -1;
@@ -351,7 +354,7 @@ public final class SvnUtil
}
catch (NumberFormatException ex)
{
throw new RevisionNotFoundException(revision);
throw notFound(entity("Revision", revision).in(repository));
}
}

View File

@@ -98,7 +98,7 @@ public class SvnBlameCommand extends AbstractSvnCommand implements BlameCommand
}
catch (SVNException ex)
{
throw new InternalRepositoryException("could not create blame result", ex);
throw new InternalRepositoryException(repository, "could not create blame result", ex);
}
return new BlameResult(blameLines.size(), blameLines);

View File

@@ -48,7 +48,6 @@ import org.tmatesoft.svn.core.io.SVNRepository;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.FileObject;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RevisionNotFoundException;
import sonia.scm.repository.SubRepository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.util.Util;
@@ -79,9 +78,9 @@ public class SvnBrowseCommand extends AbstractSvnCommand
@Override
@SuppressWarnings("unchecked")
public BrowserResult getBrowserResult(BrowseCommandRequest request) throws RevisionNotFoundException {
public BrowserResult getBrowserResult(BrowseCommandRequest request) {
String path = Strings.nullToEmpty(request.getPath());
long revisionNumber = SvnUtil.getRevisionNumber(request.getRevision());
long revisionNumber = SvnUtil.getRevisionNumber(request.getRevision(), repository);
if (logger.isDebugEnabled()) {
logger.debug("browser repository {} in path \"{}\" at revision {}", repository.getName(), path, revisionNumber);

View File

@@ -44,9 +44,7 @@ import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.PathNotFoundException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RevisionNotFoundException;
import sonia.scm.repository.SvnUtil;
import java.io.ByteArrayInputStream;
@@ -54,6 +52,9 @@ import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
import static sonia.scm.NotFoundException.notFound;
//~--- JDK imports ------------------------------------------------------------
/**
@@ -79,7 +80,7 @@ public class SvnCatCommand extends AbstractSvnCommand implements CatCommand
//~--- get methods ----------------------------------------------------------
@Override
public void getCatResult(CatCommandRequest request, OutputStream output) throws RevisionNotFoundException, PathNotFoundException {
public void getCatResult(CatCommandRequest request, OutputStream output) {
if (logger.isDebugEnabled())
{
logger.debug("try to get content for {}", request);
@@ -96,14 +97,14 @@ public class SvnCatCommand extends AbstractSvnCommand implements CatCommand
else
{
long revisionNumber = SvnUtil.getRevisionNumber(revision);
long revisionNumber = SvnUtil.getRevisionNumber(revision, repository);
getCatFromRevision(request, output, revisionNumber);
}
}
@Override
public InputStream getCatResultStream(CatCommandRequest request) throws RevisionNotFoundException, PathNotFoundException {
public InputStream getCatResultStream(CatCommandRequest request) {
// There seems to be no method creating an input stream as a result, so
// we have no other possibility then to copy the content into a buffer and
// stream it from there.
@@ -112,7 +113,7 @@ public class SvnCatCommand extends AbstractSvnCommand implements CatCommand
return new ByteArrayInputStream(output.toByteArray());
}
private void getCatFromRevision(CatCommandRequest request, OutputStream output, long revision) throws PathNotFoundException, RevisionNotFoundException {
private void getCatFromRevision(CatCommandRequest request, OutputStream output, long revision) {
logger.debug("try to read content from revision {} and path {}", revision,
request.getPath());
@@ -129,14 +130,14 @@ public class SvnCatCommand extends AbstractSvnCommand implements CatCommand
}
}
private void handleSvnException(CatCommandRequest request, SVNException ex) throws PathNotFoundException, RevisionNotFoundException {
private void handleSvnException(CatCommandRequest request, SVNException ex) {
int svnErrorCode = ex.getErrorMessage().getErrorCode().getCode();
if (SVNErrorCode.FS_NOT_FOUND.getCode() == svnErrorCode) {
throw new PathNotFoundException(request.getPath());
throw notFound(entity("Path", request.getPath()).in("Revision", request.getRevision()).in(repository));
} else if (SVNErrorCode.FS_NO_SUCH_REVISION.getCode() == svnErrorCode) {
throw new RevisionNotFoundException(request.getRevision());
throw notFound(entity("Revision", request.getRevision()).in(repository));
} else {
throw new InternalRepositoryException("could not get content from revision", ex);
throw new InternalRepositoryException(repository, "could not get content from revision", ex);
}
}
@@ -156,7 +157,7 @@ public class SvnCatCommand extends AbstractSvnCommand implements CatCommand
}
catch (SVNException ex)
{
throw new InternalRepositoryException("could not get content from transaction", ex);
throw new InternalRepositoryException(repository, "could not get content from transaction", ex);
}
finally
{

View File

@@ -1,19 +1,19 @@
/**
/*
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* <p>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* <p>
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 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.
* 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.
*
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
* <p>
* 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
@@ -24,13 +24,11 @@
* 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.
*
* <p>
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -41,14 +39,12 @@ import org.slf4j.LoggerFactory;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.wc.DefaultSVNDiffGenerator;
import org.tmatesoft.svn.core.wc.ISVNDiffGenerator;
import org.tmatesoft.svn.core.internal.wc2.ng.SvnNewDiffGenerator;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNDiffClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RevisionNotFoundException;
import sonia.scm.repository.SvnUtil;
import sonia.scm.repository.api.DiffFormat;
import sonia.scm.util.Util;
@@ -61,8 +57,7 @@ import java.io.OutputStream;
*
* @author Sebastian Sdorra
*/
public class SvnDiffCommand extends AbstractSvnCommand implements DiffCommand
{
public class SvnDiffCommand extends AbstractSvnCommand implements DiffCommand {
/**
* the logger for SvnDiffCommand
@@ -70,61 +65,37 @@ public class SvnDiffCommand extends AbstractSvnCommand implements DiffCommand
private static final Logger logger =
LoggerFactory.getLogger(SvnDiffCommand.class);
public SvnDiffCommand(SvnContext context, Repository repository)
{
public SvnDiffCommand(SvnContext context, Repository repository) {
super(context, repository);
}
@Override
public void getDiffResult(DiffCommandRequest request, OutputStream output) throws RevisionNotFoundException {
if (logger.isDebugEnabled())
{
logger.debug("create diff for {}", request);
}
public void getDiffResult(DiffCommandRequest request, OutputStream output) {
logger.debug("create diff for {}", request);
Preconditions.checkNotNull(request, "request is required");
Preconditions.checkNotNull(output, "outputstream is required");
String path = request.getPath();
SVNClientManager clientManager = null;
try
{
try {
SVNURL svnurl = context.createUrl();
if (Util.isNotEmpty(path))
{
if (Util.isNotEmpty(path)) {
svnurl = svnurl.appendPath(path, true);
}
clientManager = SVNClientManager.newInstance();
SVNDiffClient diffClient = clientManager.getDiffClient();
ISVNDiffGenerator diffGenerator = diffClient.getDiffGenerator();
diffClient.setDiffGenerator(new SvnNewDiffGenerator(new SCMSvnDiffGenerator()));
if (diffGenerator == null)
{
diffGenerator = new DefaultSVNDiffGenerator();
}
diffGenerator.setDiffAdded(true);
diffGenerator.setDiffDeleted(true);
diffClient.setDiffGenerator(diffGenerator);
long currentRev = SvnUtil.getRevisionNumber(request.getRevision());
long currentRev = SvnUtil.getRevisionNumber(request.getRevision(), repository);
diffClient.setGitDiffFormat(request.getFormat() == DiffFormat.GIT);
diffClient.doDiff(svnurl, SVNRevision.HEAD,
SVNRevision.create(currentRev - 1), SVNRevision.create(currentRev),
SVNDepth.INFINITY, false, output);
}
catch (SVNException ex)
{
throw new InternalRepositoryException("could not create diff", ex);
}
finally
{
} catch (SVNException ex) {
throw new InternalRepositoryException(repository, "could not create diff", ex);
} finally {
SvnUtil.dispose(clientManager);
}
}

View File

@@ -47,7 +47,6 @@ import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RevisionNotFoundException;
import sonia.scm.repository.SvnUtil;
import sonia.scm.util.Util;
@@ -76,7 +75,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
@Override
@SuppressWarnings("unchecked")
public Changeset getChangeset(String revision) throws RevisionNotFoundException {
public Changeset getChangeset(String revision) {
Changeset changeset = null;
if (logger.isDebugEnabled())
@@ -86,7 +85,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
try
{
long revisioNumber = parseRevision(revision);
long revisioNumber = parseRevision(revision, repository);
SVNRepository repo = open();
Collection<SVNLogEntry> entries = repo.log(null, null, revisioNumber,
revisioNumber, true, true);
@@ -98,7 +97,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
}
catch (SVNException ex)
{
throw new InternalRepositoryException("could not open repository", ex);
throw new InternalRepositoryException(repository, "could not open repository", ex);
}
return changeset;
@@ -106,7 +105,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
@Override
@SuppressWarnings("unchecked")
public ChangesetPagingResult getChangesets(LogCommandRequest request) throws RevisionNotFoundException {
public ChangesetPagingResult getChangesets(LogCommandRequest request) {
if (logger.isDebugEnabled())
{
logger.debug("fetch changesets for {}", request);
@@ -115,8 +114,8 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
ChangesetPagingResult changesets = null;
int start = request.getPagingStart();
int limit = request.getPagingLimit();
long startRevision = parseRevision(request.getStartChangeset());
long endRevision = parseRevision(request.getEndChangeset());
long startRevision = parseRevision(request.getStartChangeset(), repository);
long endRevision = parseRevision(request.getEndChangeset(), repository);
String[] pathArray = null;
if (!Strings.isNullOrEmpty(request.getPath()))
@@ -140,7 +139,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
}
catch (SVNException ex)
{
throw new InternalRepositoryException("could not open repository", ex);
throw new InternalRepositoryException(repository, "could not open repository", ex);
}
return changesets;

View File

@@ -7,11 +7,9 @@ import org.tmatesoft.svn.core.io.SVNRepository;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Modifications;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RevisionNotFoundException;
import sonia.scm.repository.SvnUtil;
import sonia.scm.util.Util;
import java.io.IOException;
import java.util.Collection;
@Slf4j
@@ -24,11 +22,11 @@ public class SvnModificationsCommand extends AbstractSvnCommand implements Modif
@Override
@SuppressWarnings("unchecked")
public Modifications getModifications(String revision) throws IOException, RevisionNotFoundException {
public Modifications getModifications(String revision) {
Modifications modifications = null;
log.debug("get modifications {}", revision);
try {
long revisionNumber = SvnUtil.parseRevision(revision);
long revisionNumber = SvnUtil.parseRevision(revision, repository);
SVNRepository repo = open();
Collection<SVNLogEntry> entries = repo.log(null, null, revisionNumber,
revisionNumber, true, true);
@@ -36,13 +34,13 @@ public class SvnModificationsCommand extends AbstractSvnCommand implements Modif
modifications = SvnUtil.createModifications(entries.iterator().next(), revision);
}
} catch (SVNException ex) {
throw new InternalRepositoryException("could not open repository", ex);
throw new InternalRepositoryException(repository, "could not open repository", ex);
}
return modifications;
}
@Override
public Modifications getModifications(ModificationsCommandRequest request) throws IOException, RevisionNotFoundException {
public Modifications getModifications(ModificationsCommandRequest request) {
return getModifications(request.getRevision());
}

View File

@@ -0,0 +1,107 @@
//@flow
import React from "react";
import type { Links } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import { InputField, Checkbox, Select } from "@scm-manager/ui-components";
type Configuration = {
repositoryDirectory: string,
compatibility: string,
enabledGZip: boolean,
disabled: boolean,
_links: Links
};
type Props = {
initialConfiguration: Configuration,
readOnly: boolean,
onConfigurationChange: (Configuration, boolean) => void,
// context props
t: (string) => string
}
type State = Configuration;
class HgConfigurationForm extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { ...props.initialConfiguration, validationErrors: [] };
}
isValid = () => {
return !!this.state.repositoryDirectory;
};
handleChange = (value: any, name: string) => {
this.setState({
[name]: value
}, () => this.props.onConfigurationChange(this.state, this.isValid()));
};
compatibilityOptions = (values: string[]) => {
const options = [];
for (let value of values) {
options.push( this.compatibilityOption(value) );
}
return options;
};
compatibilityOption = (value: string) => {
return {
value,
label: this.props.t("scm-svn-plugin.config.compatibility-values." + value.toLowerCase())
};
};
render() {
const { readOnly, t } = this.props;
const compatibilityOptions = this.compatibilityOptions([
"NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17"
]);
return (
<>
<InputField
name="repositoryDirectory"
label={t("scm-svn-plugin.config.directory")}
helpText={t("scm-svn-plugin.config.directoryHelpText")}
value={this.state.repositoryDirectory}
errorMessage={t("scm-svn-plugin.config.required")}
validationError={!this.state.repositoryDirectory}
onChange={this.handleChange}
disabled={readOnly}
/>
<Select
name="compatibility"
label={t("scm-svn-plugin.config.compatibility")}
helpText={t("scm-svn-plugin.config.compatibilityHelpText")}
value={this.state.compatibility}
options={compatibilityOptions}
onChange={this.handleChange}
/>
<Checkbox
name="enabledGZip"
label={t("scm-svn-plugin.config.enabledGZip")}
helpText={t("scm-svn-plugin.config.enabledGZipHelpText")}
checked={this.state.enabledGZip}
onChange={this.handleChange}
disabled={readOnly}
/>
<Checkbox
name="disabled"
label={t("scm-svn-plugin.config.disabled")}
helpText={t("scm-svn-plugin.config.disabledHelpText")}
checked={this.state.disabled}
onChange={this.handleChange}
disabled={readOnly}
/>
</>
);
}
}
export default translate("plugins")(HgConfigurationForm);

View File

@@ -0,0 +1,28 @@
//@flow
import React from "react";
import { translate } from "react-i18next";
import { Title, GlobalConfiguration } from "@scm-manager/ui-components";
import SvnConfigurationForm from "./SvnConfigurationForm";
type Props = {
link: string,
// context props
t: (string) => string
}
class SvnGlobalConfiguration extends React.Component<Props> {
render() {
const { link, t } = this.props;
return (
<div>
<Title title={t("scm-svn-plugin.config.title")}/>
<GlobalConfiguration link={link} render={props => <SvnConfigurationForm {...props} />}/>
</div>
);
}
}
export default translate("plugins")(SvnGlobalConfiguration);

View File

@@ -1,7 +1,9 @@
// @flow
import { binder } from "@scm-manager/ui-extensions";
import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components";
import ProtocolInformation from "./ProtocolInformation";
import SvnAvatar from "./SvnAvatar";
import SvnGlobalConfiguration from "./SvnGlobalConfiguration";
const svnPredicate = (props: Object) => {
return props.repository && props.repository.type === "svn";
@@ -9,3 +11,7 @@ const svnPredicate = (props: Object) => {
binder.bind("repos.repository-details.information", ProtocolInformation, svnPredicate);
binder.bind("repos.repository-avatar", SvnAvatar, svnPredicate);
// bind global configuration
cfgBinder.bindGlobal("/svn", "scm-svn-plugin.config.link", "svnConfig", SvnGlobalConfiguration);

View File

@@ -2,6 +2,27 @@
"scm-svn-plugin": {
"information": {
"checkout" : "Checkout repository"
},
"config": {
"link": "Subversion",
"title": "Subversion Configuration",
"directory": "Repository Directory",
"directoryHelpText": "Location of Subversion repositories.",
"compatibility": "Version Compatibility",
"compatibilityHelpText": "Specifies with which subversion version repositories are compatible.",
"compatibility-values": {
"none": "No compatibility",
"pre14": "Pre 1.4 Compatible",
"pre15": "Pre 1.5 Compatible",
"pre16": "Pre 1.6 Compatible",
"pre17": "Pre 1.7 Compatible",
"with17": "With 1.7 Compatible"
},
"enabledGZip": "Enable GZip Compression",
"enabledGZipHelpText": "Enable GZip compression for svn responses.",
"disabled": "Disabled",
"disabledHelpText": "Enable or disable the Git plugin",
"required": "This configuration value is required"
}
}
}

View File

@@ -36,7 +36,6 @@ package sonia.scm.repository.spi;
import org.junit.Test;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.FileObject;
import sonia.scm.repository.RevisionNotFoundException;
import java.io.IOException;
import java.util.Collection;
@@ -55,7 +54,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
{
@Test
public void testBrowseWithFilePath() throws RevisionNotFoundException {
public void testBrowseWithFilePath() {
BrowseCommandRequest request = new BrowseCommandRequest();
request.setPath("a.txt");
FileObject file = createCommand().getBrowserResult(request).getFile();
@@ -65,7 +64,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testBrowse() throws RevisionNotFoundException {
public void testBrowse() {
Collection<FileObject> foList = getRootFromTip(new BrowseCommandRequest());
FileObject a = getFileObject(foList, "a.txt");
@@ -89,7 +88,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
* @throws IOException
*/
@Test
public void testBrowseSubDirectory() throws RevisionNotFoundException {
public void testBrowseSubDirectory() {
BrowseCommandRequest request = new BrowseCommandRequest();
request.setPath("c");
@@ -136,7 +135,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testDisableLastCommit() throws RevisionNotFoundException {
public void testDisableLastCommit() {
BrowseCommandRequest request = new BrowseCommandRequest();
request.setDisableLastCommit(true);
@@ -150,7 +149,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testRecursive() throws RevisionNotFoundException {
public void testRecursive() {
BrowseCommandRequest request = new BrowseCommandRequest();
request.setRecursive(true);
BrowserResult result = createCommand().getBrowserResult(request);
@@ -199,7 +198,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
.orElseThrow(() -> new AssertionError("file " + name + " not found"));
}
private Collection<FileObject> getRootFromTip(BrowseCommandRequest request) throws RevisionNotFoundException {
private Collection<FileObject> getRootFromTip(BrowseCommandRequest request) {
BrowserResult result = createCommand().getBrowserResult(request);
assertNotNull(result);

View File

@@ -32,9 +32,12 @@
package sonia.scm.repository.spi;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Rule;
import org.junit.Test;
import sonia.scm.repository.PathNotFoundException;
import sonia.scm.repository.RevisionNotFoundException;
import org.junit.rules.ExpectedException;
import sonia.scm.NotFoundException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -46,8 +49,11 @@ import static org.junit.Assert.assertEquals;
public class SvnCatCommandTest extends AbstractSvnCommandTestBase {
@Rule
public final ExpectedException expectedException = ExpectedException.none();
@Test
public void testCat() throws PathNotFoundException, RevisionNotFoundException {
public void testCat() {
CatCommandRequest request = new CatCommandRequest();
request.setPath("a.txt");
@@ -56,35 +62,59 @@ public class SvnCatCommandTest extends AbstractSvnCommandTestBase {
}
@Test
public void testSimpleCat() throws PathNotFoundException, RevisionNotFoundException {
public void testSimpleCat() {
CatCommandRequest request = new CatCommandRequest();
request.setPath("c/d.txt");
assertEquals("d", execute(request));
}
@Test(expected = PathNotFoundException.class)
public void testUnknownFile() throws PathNotFoundException, RevisionNotFoundException {
@Test
public void testUnknownFile() {
CatCommandRequest request = new CatCommandRequest();
request.setPath("unknown");
request.setRevision("1");
execute(request);
}
expectedException.expect(new BaseMatcher<Object>() {
@Override
public void describeTo(Description description) {
description.appendText("expected NotFoundException for path");
}
@Test(expected = RevisionNotFoundException.class)
public void testUnknownRevision() throws PathNotFoundException, RevisionNotFoundException {
CatCommandRequest request = new CatCommandRequest();
request.setPath("a.txt");
request.setRevision("42");
@Override
public boolean matches(Object item) {
return "Path".equals(((NotFoundException)item).getContext().get(0).getType());
}
});
execute(request);
}
@Test
public void testSimpleStream() throws IOException, PathNotFoundException, RevisionNotFoundException {
public void testUnknownRevision() {
CatCommandRequest request = new CatCommandRequest();
request.setPath("a.txt");
request.setRevision("42");
expectedException.expect(new BaseMatcher<Object>() {
@Override
public void describeTo(Description description) {
description.appendText("expected NotFoundException for revision");
}
@Override
public boolean matches(Object item) {
return "Revision".equals(((NotFoundException)item).getContext().get(0).getType());
}
});
execute(request);
}
@Test
public void testSimpleStream() throws IOException {
CatCommandRequest request = new CatCommandRequest();
request.setPath("a.txt");
request.setRevision("1");
@@ -98,7 +128,7 @@ public class SvnCatCommandTest extends AbstractSvnCommandTestBase {
catResultStream.close();
}
private String execute(CatCommandRequest request) throws PathNotFoundException, RevisionNotFoundException {
private String execute(CatCommandRequest request) {
String content = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();

View File

@@ -38,7 +38,6 @@ import org.junit.Test;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.Modifications;
import sonia.scm.repository.RevisionNotFoundException;
import java.io.IOException;
@@ -57,7 +56,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
{
@Test
public void testGetAll() throws RevisionNotFoundException {
public void testGetAll() {
ChangesetPagingResult result =
createCommand().getChangesets(new LogCommandRequest());
@@ -67,7 +66,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testGetAllByPath() throws RevisionNotFoundException {
public void testGetAllByPath() {
LogCommandRequest request = new LogCommandRequest();
request.setPath("a.txt");
@@ -83,7 +82,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testGetAllWithLimit() throws RevisionNotFoundException {
public void testGetAllWithLimit() {
LogCommandRequest request = new LogCommandRequest();
request.setPagingLimit(2);
@@ -106,7 +105,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testGetAllWithPaging() throws RevisionNotFoundException {
public void testGetAllWithPaging() {
LogCommandRequest request = new LogCommandRequest();
request.setPagingStart(1);
@@ -130,7 +129,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testGetCommit() throws RevisionNotFoundException, IOException {
public void testGetCommit() {
Changeset c = createCommand().getChangeset("3");
assertNotNull(c);
@@ -151,7 +150,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
}
@Test
public void testGetRange() throws RevisionNotFoundException {
public void testGetRange() {
LogCommandRequest request = new LogCommandRequest();
request.setStartChangeset("2");