merge with develop branch

This commit is contained in:
Sebastian Sdorra
2020-06-16 19:39:27 +02:00
29 changed files with 1804 additions and 133 deletions

View File

@@ -9,10 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Option to configure jvm parameter of docker container with env JAVA_OPTS or with arguments ([#1175](https://github.com/scm-manager/scm-manager/pull/1175))
- Added links in diff views to expand the gaps between "hunks" ([#1178](https://github.com/scm-manager/scm-manager/pull/1178))
- Show commit contributors in table on changeset details view ([#1169](https://github.com/scm-manager/scm-manager/pull/1169))
- Show changeset parents on changeset details view ([#1189](https://github.com/scm-manager/scm-manager/pull/1189))
### Fixed
- Avoid caching of detected browser language ([#1176](https://github.com/scm-manager/scm-manager/pull/1176))
- Fixes configuration of jetty listener address with system property `jetty.host` ([#1173](https://github.com/scm-manager/scm-manager/pull/1173), [#1174](https://github.com/scm-manager/scm-manager/pull/1174))
- Fixes loading plugin bundles with context path `/` ([#1182](https://github.com/scm-manager/scm-manager/pull/1182/files), [#1181](https://github.com/scm-manager/scm-manager/issues/1181))
- Sets the new plugin center URL once ([#1184](https://github.com/scm-manager/scm-manager/pull/1184))
- Use command in javahg.py from registrar (Upgrade to newer javahg version) ([#1192](https://github.com/scm-manager/scm-manager/pull/1192))
## [2.0.0] - 2020-06-04
### Added

View File

@@ -8,7 +8,7 @@
"scripts": {
"build": "webpack --mode=production --config=scm-ui/ui-scripts/src/webpack.config.js",
"build:dev": "webpack --mode=development --config=scm-ui/ui-scripts/src/webpack.config.js",
"test": "lerna run --scope '@scm-manager/ui-*' test",
"test": "lerna run --scope '@scm-manager/ui-*' --scope '@scm-manager/eslint-config' test",
"typecheck": "lerna run --scope '@scm-manager/ui-*' typecheck",
"serve": "NODE_ENV=development webpack-dev-server --hot --mode=development --config=scm-ui/ui-scripts/src/webpack.config.js",
"deploy": "ui-scripts publish",

View File

@@ -20,6 +20,6 @@
},
"prettier": "@scm-manager/prettier-config",
"dependencies": {
"@scm-manager/ui-plugins": "^2.0.0"
"@scm-manager/ui-plugins": "^2.1.0-SNAPSHOT"
}
}

View File

@@ -19,6 +19,6 @@
},
"prettier": "@scm-manager/prettier-config",
"dependencies": {
"@scm-manager/ui-plugins": "^2.0.0"
"@scm-manager/ui-plugins": "^2.1.0-SNAPSHOT"
}
}

View File

@@ -44,7 +44,7 @@
<dependency>
<groupId>com.aragost.javahg</groupId>
<artifactId>javahg</artifactId>
<version>0.13-java7</version>
<version>0.14</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>

View File

@@ -19,6 +19,6 @@
},
"prettier": "@scm-manager/prettier-config",
"dependencies": {
"@scm-manager/ui-plugins": "^2.0.0"
"@scm-manager/ui-plugins": "^2.1.0-SNAPSHOT"
}
}

View File

@@ -19,6 +19,6 @@
},
"prettier": "@scm-manager/prettier-config",
"dependencies": {
"@scm-manager/ui-plugins": "^2.0.0"
"@scm-manager/ui-plugins": "^2.1.0-SNAPSHOT"
}
}

View File

@@ -2,16 +2,20 @@
"name": "@scm-manager/eslint-config",
"version": "2.0.0",
"description": "ESLint configuration for scm-manager and its plugins",
"main": "index.js",
"main": "src/index.js",
"author": "Sebastian Sdorra <s.sdorra@gmail.com>",
"license": "MIT",
"private": false,
"scripts": {
"test": "jest"
},
"prettier": "@scm-manager/prettier-config",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^2.12.0",
"@typescript-eslint/parser": "^2.12.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.5.1",
"eslint": "^7.2.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.4.0",
"eslint-config-react-app": "^5.0.2",
"eslint-plugin-flowtype": "^4.3.0",
@@ -21,6 +25,9 @@
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.1.2"
},
"devDependencies": {
"jest": "^26.0.1"
},
"publishConfig": {
"access": "public"
}

View File

@@ -21,36 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
module.exports = {
extends: [
"react-app",
"plugin:prettier/recommended",
"plugin:flowtype/recommended"
],
rules: {
semi: ["error", "always"],
quotes: ["error", "double"],
"jsx-a11y/href-no-hash": [0],
"flowtype/no-types-missing-file-annotation": 2,
"no-console": "error"
},
overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
extends: [
"react-app",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
rules: {
semi: ["error", "always"],
quotes: ["error", "double"],
"jsx-a11y/href-no-hash": [0],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/ban-ts-ignore": "warn",
"no-console": "error"
}
}
]
};
import React, { FC } from "react";
import { Button } from "@scm-manager/ui-components";
const SpecialButton: FC = () => <Button color="primary">Special</Button>;
export default SpecialButton;

View File

@@ -0,0 +1,30 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import React, { FC } from "react";
import Button from "@scm-manager/ui-components/src/buttons/Button";
const SpecialButton: FC = () => <Button color="primary">Special</Button>;
export default SpecialButton;

View File

@@ -0,0 +1,26 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var path = require('path')
console.log('we do not use path')

View File

@@ -0,0 +1,26 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const path = require('path');
console.log("from typscript");

View File

@@ -0,0 +1,25 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
console.log('from Sample.tsx')

View File

@@ -0,0 +1,94 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const rules = {
"prettier/prettier": "warn",
semi: ["error", "always"],
quotes: ["error", "double", "avoid-escape"],
"no-var": "error"
};
const nodeConfiguration = {
extends: ["airbnb-base", "plugin:prettier/recommended"],
rules: {
"no-console": "off",
...rules
}
};
const restrictImportConfig = {
patterns: ["@scm-manager/*/*"]
};
const typescriptConfiguration = {
parser: "@typescript-eslint/parser",
extends: ["react-app", "plugin:@typescript-eslint/recommended"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/ban-ts-ignore": "warn",
"no-console": "error",
"jsx-a11y/href-no-hash": "off",
"no-restricted-imports": ["error", restrictImportConfig],
...rules
}
};
module.exports = {
overrides: [
{
files: ["*.test.js"],
env: {
node: true,
jest: true,
browser: false
},
...nodeConfiguration
},
{
files: ["*.js"],
env: {
node: true,
browser: false
},
...nodeConfiguration
},
{
files: ["*.test.ts", "*.test.tsx"],
env: {
node: true,
jest: true,
browser: false
},
...typescriptConfiguration
},
{
files: ["*.ts", "*.tsx"],
env: {
node: false,
browser: true
},
...typescriptConfiguration
}
]
};

View File

@@ -0,0 +1,79 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const { ESLint } = require("eslint");
const path = require("path");
const eslint = new ESLint();
const resource = path.join(__dirname, "__resources__");
const lint = async file => {
const results = await eslint.lintFiles([path.join(resource, file)]);
const { messages } = results[0];
const warnings = messages.filter(m => m.severity === 1).map(m => m.ruleId);
const errors = messages.filter(m => m.severity === 2).map(m => m.ruleId);
return {
errors,
warnings
};
};
const expectContains = (results, ...ids) => {
ids.forEach(id => expect(results).toContain(id));
};
describe("should lint different file types", () => {
it("should lint tsx files", async () => {
const { errors, warnings } = await lint("TypescriptWithJsx.tsx");
expectContains(errors, "no-console", "quotes", "semi");
expectContains(warnings, "prettier/prettier");
});
it("should lint js files", async () => {
const { errors, warnings } = await lint("Node.js");
expectContains(errors, "no-var", "quotes", "semi");
expectContains(warnings, "prettier/prettier");
});
it("should lint ts files", async () => {
const { errors, warnings } = await lint("Typescript.ts");
expectContains(errors, "no-console", "quotes");
expectContains(warnings, "prettier/prettier");
});
});
describe("lint @scm-manager imports", () => {
it("should return an error for source imports", async () => {
const { errors } = await lint("AvoidSourceImport.tsx");
expectContains(errors, "no-restricted-imports");
});
it("should return no error for package imports", async () => {
const { errors, warnings } = await lint("AllowRootImport.tsx");
expect(errors).toEqual([]);
expect(warnings).toEqual([]);
});
});

View File

@@ -1,6 +1,6 @@
{
"name": "@scm-manager/ui-components",
"version": "2.0.0",
"version": "2.1.0-SNAPSHOT",
"description": "UI Components for SCM-Manager and its plugins",
"main": "src/index.ts",
"files": [
@@ -47,7 +47,7 @@
},
"dependencies": {
"@scm-manager/ui-extensions": "^2.0.0",
"@scm-manager/ui-types": "^2.0.0",
"@scm-manager/ui-types": "^2.1.0-SNAPSHOT",
"classnames": "^2.2.6",
"date-fns": "^2.4.1",
"gitdiff-parser": "^0.1.2",

View File

@@ -92,7 +92,7 @@ export const SingleContributor: FC<PersonProps> = ({ person, className, displayT
};
type PersonsProps = {
persons: Person[];
persons: ReadonlyArray<Person>;
label: string;
displayTextOnly?: boolean;
};
@@ -133,7 +133,7 @@ const Contributors: FC<PersonsProps> = ({ persons, label, displayTextOnly }) =>
}
};
const emptyListOfContributors: Person[] = [];
const emptyListOfContributors: ReadonlyArray<Person> = [];
const ChangesetAuthor: FC<Props> = ({ changeset }) => {
const binder = useBinder();
@@ -173,7 +173,7 @@ const ChangesetAuthor: FC<Props> = ({ changeset }) => {
// extensions
const extensions = binder.getExtensions("changesets.author.suffix", { changeset });
if (extensions) {
coAuthors.push(...extensions);
authorLine.push(...extensions);
}
return <CommaSeparatedList>{authorLine}</CommaSeparatedList>;

View File

@@ -1,12 +1,12 @@
{
"name": "@scm-manager/ui-plugins",
"version": "2.0.0",
"version": "2.1.0-SNAPSHOT",
"license": "MIT",
"bin": {
"ui-plugins": "./bin/ui-plugins.js"
},
"dependencies": {
"@scm-manager/ui-components": "^2.0.0",
"@scm-manager/ui-components": "^2.1.0-SNAPSHOT",
"@scm-manager/ui-extensions": "^2.0.0",
"classnames": "^2.2.6",
"query-string": "^5.0.1",
@@ -25,7 +25,7 @@
"@scm-manager/tsconfig": "^2.0.0",
"@scm-manager/ui-scripts": "^2.0.0",
"@scm-manager/ui-tests": "^2.0.0",
"@scm-manager/ui-types": "^2.0.0",
"@scm-manager/ui-types": "^2.1.0-SNAPSHOT",
"@types/classnames": "^2.2.9",
"@types/enzyme": "^3.10.3",
"@types/fetch-mock": "^7.3.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@scm-manager/ui-types",
"version": "2.0.0",
"version": "2.1.0-SNAPSHOT",
"description": "Flow types for SCM-Manager related Objects",
"main": "src/index.ts",
"files": [

View File

@@ -1,9 +1,9 @@
{
"name": "@scm-manager/ui-webapp",
"version": "2.0.0",
"version": "2.1.0-SNAPSHOT",
"private": true,
"dependencies": {
"@scm-manager/ui-components": "^2.0.0",
"@scm-manager/ui-components": "^2.1.0-SNAPSHOT",
"@scm-manager/ui-extensions": "^2.0.0",
"classnames": "^2.2.5",
"history": "^4.10.1",

View File

@@ -18,7 +18,7 @@
"errorTitle": "Fehler",
"errorSubtitle": "Unbekannter Gruppen Fehler",
"menu": {
"navigationLabel": "Gruppen",
"navigationLabel": "Gruppe",
"informationNavLink": "Informationen",
"settingsNavLink": "Einstellungen",
"generalNavLink": "Generell",

View File

@@ -87,6 +87,10 @@
"shortSummary": "Committet <0/> <1/>",
"tags": "Tags",
"diffNotSupported": "Diff des Changesets wird von diesem Repositorytyp nicht unterstützt",
"parents": {
"label" : "Parent",
"label_plural": "Parents"
},
"contributors": {
"mailto": "Mail senden an",
"list": "Liste der Mitwirkenden",

View File

@@ -91,6 +91,10 @@
"details": "Details",
"sources": "Sources"
},
"parents": {
"label" : "Parent",
"label_plural": "Parents"
},
"contributors": {
"mailto": "Send mail to",
"list": "List of contributors",

View File

@@ -26,7 +26,7 @@ import { Trans, useTranslation, WithTranslation, withTranslation } from "react-i
import classNames from "classnames";
import styled from "styled-components";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { Changeset, Repository, Tag } from "@scm-manager/ui-types";
import { Changeset, Repository, Tag, ParentChangeset } from "@scm-manager/ui-types";
import {
AvatarImage,
AvatarWrapper,
@@ -41,6 +41,7 @@ import {
Icon
} from "@scm-manager/ui-components";
import ContributorTable from "./ContributorTable";
import { Link as ReactLink } from "react-router-dom";
type Props = WithTranslation & {
changeset: Changeset;
@@ -102,6 +103,19 @@ const ContributorToggleLine = styled.p`
margin-bottom: 0.5rem !important;
`;
const ChangesetSummary = styled.div`
display: flex;
justify-content: space-between;
`
const SeparatedParents = styled.div`
margin-left: 1em;
a + a:before {
content: ",\\00A0";
color: #4a4a4a;
}
`;
const Contributors: FC<{ changeset: Changeset }> = ({ changeset }) => {
const [t] = useTranslation("repos");
const [open, setOpen] = useState(false);
@@ -148,6 +162,11 @@ class ChangesetDetails extends React.Component<Props, State> {
const description = changesets.parseDescription(changeset.description);
const id = <ChangesetId repository={repository} changeset={changeset} link={false} />;
const date = <DateFromNow date={changeset.date} />;
const parents = changeset._embedded.parents.map((parent: ParentChangeset) => (
<ReactLink title={parent.id} to={parent.id}>
{parent.id.substring(0, 7)}
</ReactLink>
));
return (
<>
@@ -172,9 +191,17 @@ class ChangesetDetails extends React.Component<Props, State> {
</AvatarWrapper>
<div className="media-content is-ellipsis-overflow">
<Contributors changeset={changeset} />
<ChangesetSummary>
<p>
<Trans i18nKey="repos:changeset.summary" components={[id, date]} />
</p>
{parents?.length > 0 && (
<SeparatedParents>
{t("changeset.parents.label", { count: parents?.length }) + ": "}
{parents}
</SeparatedParents>
)}
</ChangesetSummary>
</div>
<div className="media-right">{this.renderTags()}</div>
</article>

View File

@@ -53,6 +53,12 @@ class ChangesetView extends React.Component<Props> {
fetchChangesetIfNeeded(repository, id);
}
componentDidUpdate() {
const { fetchChangesetIfNeeded, repository } = this.props;
const id = this.props.match.params.id;
fetchChangesetIfNeeded(repository, id);
}
render() {
const { changeset, loading, error, t, repository } = this.props;

View File

@@ -77,7 +77,7 @@ public class UIPluginDtoMapper {
private String addContextPath(String resource) {
String ctxPath = request.getContextPath();
if (Strings.isNullOrEmpty(ctxPath)) {
return resource;
return "/" + resource;
}
return HttpUtil.append(ctxPath, resource);
}

View File

@@ -0,0 +1,70 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.update.plugin;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.migration.UpdateStep;
import sonia.scm.plugin.Extension;
import sonia.scm.store.ConfigurationStore;
import sonia.scm.store.ConfigurationStoreFactory;
import sonia.scm.version.Version;
import javax.inject.Inject;
import static sonia.scm.version.Version.parse;
@Extension
public class PluginCenterUpdateStep implements UpdateStep {
private final ConfigurationStoreFactory configurationStoreFactory;
@Inject
public PluginCenterUpdateStep(ConfigurationStoreFactory configurationStoreFactory) {
this.configurationStoreFactory = configurationStoreFactory;
}
@Override
public void doUpdate() {
ConfigurationStore<ScmConfiguration> configurationStore = configurationStoreFactory
.withType(ScmConfiguration.class)
.withName("config")
.build();
configurationStore.getOptional()
.ifPresent(config -> {
config.setPluginUrl(ScmConfiguration.DEFAULT_PLUGINURL);
configurationStore.set(config);
});
}
@Override
public Version getTargetVersion() {
return parse("2.0.0");
}
@Override
public String getAffectedDataType() {
return "sonia.scm.plugin-center";
}
}

View File

@@ -0,0 +1,58 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.update.plugin;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.store.ConfigurationStore;
import sonia.scm.store.InMemoryConfigurationStoreFactory;
import static org.assertj.core.api.Assertions.assertThat;
class PluginCenterUpdateStepTest {
@Test
void shouldNotCreateConfigIfNoConfigIsPresent() {
InMemoryConfigurationStoreFactory configurationStoreFactory = new InMemoryConfigurationStoreFactory();
new PluginCenterUpdateStep(configurationStoreFactory)
.doUpdate();
ScmConfiguration config = configurationStoreFactory.withType(ScmConfiguration.class).withName("config").build().get();
assertThat(config).isNull();
}
@Test
void shouldOverwriteOldPluginCenterUrl() {
InMemoryConfigurationStoreFactory configurationStoreFactory = new InMemoryConfigurationStoreFactory();
ConfigurationStore<ScmConfiguration> configurationStore = configurationStoreFactory.withType(ScmConfiguration.class).withName("config").build();
ScmConfiguration scmConfiguration = new ScmConfiguration();
scmConfiguration.setPluginUrl("http://some.old/url");
configurationStore.set(scmConfiguration);
new PluginCenterUpdateStep(configurationStoreFactory)
.doUpdate();
ScmConfiguration config = configurationStore.get();
assertThat(config.getPluginUrl()).isEqualTo(ScmConfiguration.DEFAULT_PLUGINURL);
}
}

1385
yarn.lock

File diff suppressed because it is too large Load Diff