From 9e9d0ad028680e6fc4ef28f1d5985f74e411af95 Mon Sep 17 00:00:00 2001 From: Michal Duda Date: Thu, 14 Nov 2019 13:43:53 +0100 Subject: [PATCH] SONAR-12628 remove configuration setting "sonar.branch.longLivedBranches.regex" --- .../db/migration/version/v81/DbVersion81.java | 6 +- .../version/v81/RemoveLLBRegexSetting.java} | 35 +++-- .../version/v81/DbVersion81Test.java | 2 +- .../v81/RemoveLLBRegexSettingTest.java | 86 +++++++++++ .../v81/RemoveLLBRegexSettingTest/schema.sql | 11 ++ .../apps/projectBranches/components/App.tsx | 2 - .../components/LongBranchesPattern.tsx | 101 ------------- .../components/LongBranchesPatternForm.tsx | 43 ------ .../components/SettingForm.tsx | 140 ------------------ .../__tests__/LongBranchesPattern-test.tsx | 68 --------- .../components/__tests__/SettingForm-test.tsx | 87 ----------- .../__tests__/__snapshots__/App-test.tsx.snap | 3 - .../LongBranchesPattern-test.tsx.snap | 17 --- .../LongBranchesPatternForm-test.tsx.snap | 27 ---- .../__snapshots__/SettingForm-test.tsx.snap | 109 -------------- .../main/js/apps/settings/store/actions.ts | 7 +- .../resources/org/sonar/l10n/core.properties | 4 - .../java/org/sonar/api/CoreProperties.java | 5 - 18 files changed, 123 insertions(+), 630 deletions(-) rename server/{sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx => sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java} (57%) create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java index e51407ffd2f..912861e3c6f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java @@ -28,13 +28,15 @@ public class DbVersion81 implements DbVersion { registry .add(3100, "Create ALM_SETTINGS table", CreateAlmSettingsTable.class) .add(3101, "Create PROJECT_ALM_SETTINGS table", CreateProjectAlmSettingsTable.class) - .add(3102, "Migrate property 'sonar.alm.github.app.privateKey.secured' to 'sonar.alm.github.app.privateKeyContent.secured'", MigrateDeprecatedGithubPrivateKeyToNewKey.class) + .add(3102, "Migrate property 'sonar.alm.github.app.privateKey.secured' to 'sonar.alm.github.app.privateKeyContent.secured'", + MigrateDeprecatedGithubPrivateKeyToNewKey.class) .add(3103, "Migrate GitHub ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateGithubAlmSettings.class) .add(3104, "Migrate Bitbucket ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateBitbucketAlmSettings.class) .add(3105, "Migrate Azure ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateAzureAlmSettings.class) .add(3106, "Delete 'sonar.pullrequest.provider' property", DeleteSonarPullRequestProviderProperty.class) .add(3107, "Migrate default branches to keep global setting", MigrateDefaultBranchesToKeepSetting.class) .add(3108, "Add EXCLUDE_FROM_PURGE column", AddExcludeBranchFromPurgeColumn.class) - .add(3109, "Populate EXCLUDE_FROM_PURGE column", PopulateExcludeBranchFromPurgeColumn.class); + .add(3109, "Populate EXCLUDE_FROM_PURGE column", PopulateExcludeBranchFromPurgeColumn.class) + .add(3110, "Remove 'sonar.branch.longLivedBranches.regex'", RemoveLLBRegexSetting.class); } } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java similarity index 57% rename from server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx rename to server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java index ce4508257f1..e0fcaea9aab 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java @@ -17,19 +17,24 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import LongBranchesPatternForm from '../LongBranchesPatternForm'; +package org.sonar.server.platform.db.migration.version.v81; -it('renders', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.SupportsBlueGreen; +import org.sonar.server.platform.db.migration.step.DataChange; + +@SupportsBlueGreen +public class RemoveLLBRegexSetting extends DataChange { + + public RemoveLLBRegexSetting(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + context.prepareUpsert("delete from properties where prop_key='sonar.branch.longLivedBranches.regex'") + .execute() + .commit(); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java index 45f8522bf48..cb64c2f6f88 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java @@ -37,7 +37,7 @@ public class DbVersion81Test { @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 10); + verifyMigrationCount(underTest, 11); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java new file mode 100644 index 00000000000..86a9a337c25 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java @@ -0,0 +1,86 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v81; + +import java.sql.SQLException; +import java.time.Instant; +import javax.annotation.Nullable; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +import static java.lang.String.format; +import static org.junit.Assert.assertEquals; + +public class RemoveLLBRegexSettingTest { + + private static final String PROPERTIES_TABLE_NAME = "properties"; + private static final int TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES = 10; + + @Rule + public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveLLBRegexSettingTest.class, "schema.sql"); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private RemoveLLBRegexSetting underTest = new RemoveLLBRegexSetting(dbTester.database()); + + @Before + public void setup() { + insertProperty(null, "xyz"); + for (long i = 1; i <= TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES; i++) { + insertProperty(i, format("xyz-%s", i)); + } + + int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); + assertEquals(TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 1, propertiesCount); + } + + @Test + public void remove_llb_regex_property() throws SQLException { + underTest.execute(); + + verifyResult(); + } + + @Test + public void migration_is_re_entrant() throws SQLException { + underTest.execute(); + underTest.execute(); + + verifyResult(); + } + + private void verifyResult() { + int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME); + assertEquals(0, propertiesCount); + } + + private void insertProperty(@Nullable Long projectId, String propertyValue) { + dbTester.executeInsert(PROPERTIES_TABLE_NAME, + "prop_key", "sonar.branch.longLivedBranches.regex", + "resource_id", projectId, + "is_empty", false, + "text_value", propertyValue, + "created_at", Instant.now().toEpochMilli()); + } +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql new file mode 100644 index 00000000000..367029ea6ba --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE "PROPERTIES" ( + "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1), + "PROP_KEY" VARCHAR(512) NOT NULL, + "RESOURCE_ID" INTEGER, + "USER_ID" INTEGER, + "IS_EMPTY" BOOLEAN NOT NULL, + "TEXT_VALUE" VARCHAR(4000), + "CLOB_VALUE" CLOB, + "CREATED_AT" BIGINT +); +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx index 83a78038dcd..ade615895f2 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx @@ -31,7 +31,6 @@ import { sortBranchesAsTree } from '../../../helpers/branches'; import BranchRow from './BranchRow'; -import LongBranchesPattern from './LongBranchesPattern'; interface Props { branchLikes: T.BranchLike[]; @@ -126,7 +125,6 @@ export default class App extends React.PureComponent {

{translate('project_branches.page')}

-

{translate('project_branches.page.description')}

{this.renderBranchLifeTime()}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx deleted file mode 100644 index 0199d201ead..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import { EditButton } from 'sonar-ui-common/components/controls/buttons'; -import { translate } from 'sonar-ui-common/helpers/l10n'; -import { getValues } from '../../../api/settings'; -import LongBranchesPatternForm from './LongBranchesPatternForm'; - -interface Props { - project: string; -} - -interface State { - formOpen: boolean; - setting?: T.SettingValue; -} - -export const LONG_BRANCH_PATTERN = 'sonar.branch.longLivedBranches.regex'; - -export default class LongBranchesPattern extends React.PureComponent { - mounted = false; - state: State = { formOpen: false }; - - componentDidMount() { - this.mounted = true; - this.fetchSetting(); - } - - componentWillUnmount() { - this.mounted = false; - } - - fetchSetting() { - return getValues({ keys: LONG_BRANCH_PATTERN, component: this.props.project }).then( - settings => { - if (this.mounted) { - this.setState({ setting: settings[0] }); - } - }, - () => {} - ); - } - - closeForm = () => { - if (this.mounted) { - this.setState({ formOpen: false }); - } - }; - - handleChangeClick = () => { - this.setState({ formOpen: true }); - }; - - handleChange = () => { - if (this.mounted) { - this.fetchSetting().then(this.closeForm, this.closeForm); - } - }; - - render() { - const { setting } = this.state; - - if (!setting) { - return null; - } - - return ( -
- {translate('branches.long_living_branches_pattern')} - {': '} - {setting.value} - - {this.state.formOpen && ( - - )} -
- ); - } -} diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx deleted file mode 100644 index a0d6816dc21..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import Modal from 'sonar-ui-common/components/controls/Modal'; -import { translate } from 'sonar-ui-common/helpers/l10n'; -import SettingForm from './SettingForm'; - -interface Props { - onChange: () => void; - onClose: () => void; - project: string; - setting: T.SettingValue; -} - -export default function LongBranchesPatternForm(props: Props) { - const header = translate('branches.detection_of_long_living_branches'); - - return ( - -
-

{header}

-
- -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx deleted file mode 100644 index 8ea209f8ad8..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import { Button, ResetButtonLink, SubmitButton } from 'sonar-ui-common/components/controls/buttons'; -import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; -import { resetSettingValue, setSimpleSettingValue } from '../../../api/settings'; -import { sanitizeTranslation } from '../../settings/utils'; - -interface Props { - branch?: string; - onClose: () => void; - onChange: () => void; - project: string; - setting: T.SettingValue; -} - -interface State { - submitting: boolean; - value?: string; -} - -export default class SettingForm extends React.PureComponent { - mounted = false; - - constructor(props: Props) { - super(props); - this.state = { submitting: false, value: props.setting.value }; - } - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - stopLoading = () => { - if (this.mounted) { - this.setState({ submitting: false }); - } - }; - - handleSubmit = (event: React.SyntheticEvent) => { - event.preventDefault(); - - const { value } = this.state; - if (!value) { - return; - } - - this.setState({ submitting: true }); - setSimpleSettingValue({ - branch: this.props.branch, - component: this.props.project, - key: this.props.setting.key, - value - }).then(this.props.onChange, this.stopLoading); - }; - - handleValueChange = (event: React.SyntheticEvent) => { - this.setState({ value: event.currentTarget.value }); - }; - - handleResetClick = () => { - this.setState({ submitting: true }); - resetSettingValue({ - keys: this.props.setting.key, - component: this.props.project, - branch: this.props.branch - }).then(this.props.onChange, this.stopLoading); - }; - - render() { - const { setting } = this.props; - const submitDisabled = this.state.submitting || this.state.value === setting.value; - - return ( -
-
-
-
- - {setting.inherited && ( -
{translate('settings._default')}
- )} - {!setting.inherited && setting.parentValue && ( -
- {translateWithParameters('settings.default_x', setting.parentValue)} -
- )} -
-
-
- {!setting.inherited && setting.parentValue && ( - - )} - {this.state.submitting && } - {translate('save')} - {translate('cancel')} -
- - ); - } -} diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx deleted file mode 100644 index 3bc76e06f47..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { click } from 'sonar-ui-common/helpers/testUtils'; -import LongBranchesPattern from '../LongBranchesPattern'; - -jest.mock('../../../../api/settings', () => ({ - getValues: jest.fn(() => Promise.resolve([])) -})); - -const getValues = require('../../../../api/settings').getValues as jest.Mock; - -beforeEach(() => { - getValues.mockClear(); -}); - -it('renders', () => { - const wrapper = shallow(); - wrapper.setState({ loading: false, setting: { value: 'release-.*' } }); - expect(wrapper).toMatchSnapshot(); -}); - -it('opens form', () => { - const wrapper = shallow(); - wrapper.setState({ loading: false, setting: { value: 'release-.*' } }); - - click(wrapper.find('EditButton')); - expect(wrapper.find('LongBranchesPatternForm').exists()).toBeTruthy(); - - wrapper.find('LongBranchesPatternForm').prop('onClose')(); - wrapper.update(); - expect(wrapper.find('LongBranchesPatternForm').exists()).toBeFalsy(); -}); - -it('fetches setting value on mount', () => { - shallow(); - expect(getValues).lastCalledWith({ - keys: 'sonar.branch.longLivedBranches.regex', - component: 'project' - }); -}); - -it('fetches new setting value after change', () => { - const wrapper = shallow(); - expect(getValues).toHaveBeenCalledTimes(1); - - (wrapper.instance() as LongBranchesPattern).handleChange(); - expect(getValues).toHaveBeenCalledTimes(2); -}); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx deleted file mode 100644 index 77b44a94311..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -/* eslint-disable import/first */ -jest.mock('../../../../api/settings', () => ({ - setSimpleSettingValue: jest.fn(() => Promise.resolve()), - resetSettingValue: jest.fn(() => Promise.resolve()) -})); - -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { change, click, submit } from 'sonar-ui-common/helpers/testUtils'; -import SettingForm from '../SettingForm'; - -const setSimpleSettingValue = require('../../../../api/settings') - .setSimpleSettingValue as jest.Mock; - -const resetSettingValue = require('../../../../api/settings').resetSettingValue as jest.Mock; - -beforeEach(() => { - setSimpleSettingValue.mockClear(); - resetSettingValue.mockClear(); -}); - -it('changes value', async () => { - const onChange = jest.fn(); - const wrapper = shallow( - - ); - expect(wrapper).toMatchSnapshot(); - - change(wrapper.find('input'), 'branch-.*'); - submit(wrapper.find('form')); - expect(setSimpleSettingValue).toBeCalledWith({ - branch: undefined, - component: 'project', - key: 'foo', - value: 'branch-.*' - }); - - await new Promise(setImmediate); - expect(onChange).toBeCalled(); -}); - -it('resets value', async () => { - const onChange = jest.fn(); - const wrapper = shallow( - - ); - expect(wrapper).toMatchSnapshot(); - - click(wrapper.find('Button')); - expect(resetSettingValue).toBeCalledWith({ - keys: 'foo', - component: 'project', - branch: undefined - }); - - await new Promise(setImmediate); - expect(onChange).toBeCalled(); -}); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap index 94ea8832c73..72cdbbb0068 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap @@ -12,9 +12,6 @@ exports[`renders sorted list of branches 1`] = ` > project_branches.page -

diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap deleted file mode 100644 index 8d1c83d3003..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` -

- branches.long_living_branches_pattern - : - - release-.* - - -
-`; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap deleted file mode 100644 index 07725582cdf..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap +++ /dev/null @@ -1,27 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` - -
-

- branches.detection_of_long_living_branches -

-
- -
-`; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap deleted file mode 100644 index 45cb96b4022..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap +++ /dev/null @@ -1,109 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`changes value 1`] = ` -
-
-
-
- -
- settings._default -
-
-
-
- - save - - - cancel - -
- -`; - -exports[`resets value 1`] = ` -
-
-
-
- -
- settings.default_x.branch-.* -
-
-
- - -`; diff --git a/server/sonar-web/src/main/js/apps/settings/store/actions.ts b/server/sonar-web/src/main/js/apps/settings/store/actions.ts index dd0b1e51316..52c3cf82a90 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/actions.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/actions.ts @@ -46,12 +46,7 @@ import { receiveValues } from './values'; export function fetchSettings(component?: string) { return (dispatch: Dispatch) => { return getDefinitions(component).then(definitions => { - const filtered = definitions - .filter(definition => definition.type !== 'LICENSE') - // do not display this setting on project level - .filter( - definition => !component || definition.key !== 'sonar.branch.longLivedBranches.regex' - ); + const filtered = definitions.filter(definition => definition.type !== 'LICENSE'); dispatch(receiveDefinitions(filtered)); }); }; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index b6c744be79e..087da2ec02a 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1037,7 +1037,6 @@ property.category.scm=SCM property.category.housekeeping=Housekeeping property.category.housekeeping.general=General property.category.housekeeping.branchesAndPullRequests=Branches and Pull Requests -property.sonar.branch.longLivedBranches.regex.description=Regular expression used to detect whether a branch is a long living branch (as opposed to short living branch), based on its name. This applies only during first analysis, the type of a branch cannot be changed later. #------------------------------------------------------------------------------ @@ -3192,9 +3191,6 @@ branches.orphan_branches=Orphan Branches & Pull Requests branches.orphan_branches.tooltip=When a target branch of a short-living branch or a base of a pull request was deleted, this short-living branch or pull request becomes orphan. branches.main_branch=Main Branch branches.branch_settings=Branch Settings -branches.long_living_branches_pattern=Long living branches pattern -branches.detection_of_long_living_branches=Detection of long living branches -branches.detection_of_long_living_branches.description=Regular expression used to detect whether a branch is a long living branch (as opposed to short living branch), based on its name. This applies only during first analysis, the type of a branch cannot be changed later. branches.set_new_code_period=Set New Code Period branches.last_analysis_date=Last Analysis Date branches.search_for_branches=Search for branches... diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index 49e92f7e7be..62356c0469e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -181,11 +181,6 @@ public interface CoreProperties { */ String PROJECT_DATE_PROPERTY = "sonar.projectDate"; - /** - * @since 6.6 - */ - String LONG_LIVED_BRANCHES_REGEX = "sonar.branch.longLivedBranches.regex"; - /* Exclusions */ String PROJECT_INCLUSIONS_PROPERTY = "sonar.inclusions"; String PROJECT_EXCLUSIONS_PROPERTY = "sonar.exclusions"; -- 2.39.5