Commit bcae549e authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '335316-change-any-branch-to-all-branches' into 'master'

Replace "Any branch" with "All branches"

See merge request gitlab-org/gitlab!70552
parents 8f157870 1b256d5a
......@@ -49,7 +49,7 @@ branch name.
Your developers may not remember that policy, so they might push to
various branches, and CI pipelines might not work as expected. By restricting the
branch names globally in Push Rules, such mistakes are prevented.
Any branch name that doesn't match your push rule is rejected.
All branch names that don't match your push rule are rejected.
Note that the name of your default branch is always allowed, regardless of the branch naming
regular expression (regex) specified. GitLab is configured this way
......@@ -109,7 +109,7 @@ The following options are available:
| Prevent pushing secret files | GitLab rejects any files that are likely to contain secrets. See the [forbidden file names](#prevent-pushing-secrets-to-the-repository). |
| Require expression in commit messages | Only commit messages that match this regular expression are allowed to be pushed. Leave empty to allow any commit message. Uses multiline mode, which can be disabled using `(?-m)`. |
| Reject expression in commit messages | Only commit messages that do not match this regular expression are allowed to be pushed. Leave empty to allow any commit message. Uses multiline mode, which can be disabled using `(?-m)`. |
| Restrict by branch name | Only branch names that match this regular expression are allowed to be pushed. Leave empty to allow any branch name. |
| Restrict by branch name | Only branch names that match this regular expression are allowed to be pushed. Leave empty to allow all branch names. |
| Restrict by commit author's email | Only commit author's email that match this regular expression are allowed to be pushed. Leave empty to allow any email. |
| Prohibited file names | Any committed filenames that match this regular expression and do not already exist in the repository are not allowed to be pushed. Leave empty to allow any filenames. See [common examples](#prohibited-file-names). |
| Maximum file size | Pushes that contain added or updated files that exceed this file size (in MB) are rejected. Set to 0 to allow files of any size. Files tracked by Git LFS are exempted. |
......
......@@ -225,7 +225,7 @@ approval rule for certain branches:
1. Go to your project and select **Settings**.
1. Expand **Merge request (MR) approvals**.
1. Select a **Target branch**:
- To protect all branches, select **Any branch**.
- To protect all branches, select **All branches**.
- To select a specific branch, select it from the list:
![Scoped to protected branch](img/scoped_to_protected_branch_v13_10.png)
......
......@@ -93,7 +93,7 @@ for doesn't appear immediately. The search box requires
**three** alphanumeric characters to be entered for the search to begin.
If you want the status check to be applied to **all** merge requests,
you can select the **Any branch** option.
you can select the **All branches** option.
## Delete a status check
......
......@@ -12,9 +12,9 @@ export default {
branchName() {
const { protectedBranches } = this.rule;
const [protectedBranch] = protectedBranches || [];
return protectedBranch?.name || __('Any branch');
return protectedBranch?.name || __('All branches');
},
isAnyBranch() {
isAllBranches() {
return this.rule.protectedBranches?.length;
},
},
......@@ -22,5 +22,5 @@ export default {
</script>
<template>
<div :class="{ monospace: isAnyBranch }">{{ branchName }}</div>
<div :class="{ monospace: isAllBranches }">{{ branchName }}</div>
</template>
......@@ -6,7 +6,7 @@ import { REPORT_TYPES, SEVERITY_LEVELS } from 'ee/security_dashboard/store/const
import ProtectedBranchesSelector from 'ee/vue_shared/components/branches_selector/protected_branches_selector.vue';
import { sprintf } from '~/locale';
import {
ANY_BRANCH,
ALL_BRANCHES,
TYPE_USER,
TYPE_GROUP,
TYPE_HIDDEN_GROUPS,
......@@ -136,7 +136,7 @@ export default {
invalidBranches() {
if (
!this.isMrEdit &&
!this.branches.every((branch) => isEqual(branch, ANY_BRANCH) || isNumber(branch?.id))
!this.branches.every((branch) => isEqual(branch, ALL_BRANCHES) || isNumber(branch?.id))
) {
return APPROVAL_DIALOG_I18N.validations.branchesRequired;
}
......
......@@ -5,9 +5,9 @@ export const TYPE_GROUP = 'group';
export const TYPE_HIDDEN_GROUPS = 'hidden_groups';
export const BRANCH_FETCH_DELAY = 250;
export const ANY_BRANCH = {
export const ALL_BRANCHES = {
id: null,
name: __('Any branch'),
name: __('All branches'),
};
export const RULE_TYPE_FALLBACK = 'fallback';
......@@ -96,7 +96,7 @@ export const APPROVAL_DIALOG_I18N = {
nameDescription: s__('ApprovalRule|Examples: QA, Security.'),
protectedBranchLabel: s__('ApprovalRule|Target branch'),
protectedBranchDescription: __(
'Apply this approval rule to any branch or a specific protected branch.',
'Apply this approval rule to all branches or a specific protected branch.',
),
scannersLabel: s__('ApprovalRule|Security scanners'),
scannersSelectLabel: s__('ApprovalRule|Select scanners'),
......
......@@ -10,16 +10,16 @@ export default {
},
},
computed: {
isAnyBranch() {
isAllBranches() {
return !this.branches?.length;
},
branchName() {
return this.isAnyBranch ? __('Any branch') : this.branches[0].name;
return this.isAllBranches ? __('All branches') : this.branches[0].name;
},
},
};
</script>
<template>
<span :class="{ monospace: isAnyBranch }">{{ branchName }}</span>
<span :class="{ monospace: isAllBranches }">{{ branchName }}</span>
</template>
......@@ -6,7 +6,7 @@ import ProtectedBranchesSelector from 'ee/vue_shared/components/branches_selecto
import { isSafeURL } from '~/lib/utils/url_utility';
import { __, s__ } from '~/locale';
import {
ANY_BRANCH,
ALL_BRANCHES,
EMPTY_STATUS_CHECK,
NAME_TAKEN_SERVER_ERROR,
URL_TAKEN_SERVER_ERROR,
......@@ -52,7 +52,7 @@ export default {
return this.isValidName && this.isValidUrl && this.isValidBranches;
},
isValidBranches() {
return this.branches.every((branch) => isEqual(branch, ANY_BRANCH) || isNumber(branch?.id));
return this.branches.every((branch) => isEqual(branch, ALL_BRANCHES) || isNumber(branch?.id));
},
isValidName() {
return Boolean(this.name);
......@@ -124,7 +124,7 @@ export default {
nameDescription: s__('StatusCheck|Examples: QA, Security.'),
protectedBranchLabel: s__('StatusCheck|Target branch'),
protectedBranchDescription: s__(
'StatusCheck|Apply this status check to any branch or a specific protected branch.',
'StatusCheck|Apply this status check to all branches or a specific protected branch.',
),
},
validations: {
......
import { __ } from '~/locale';
export const BRANCH_FETCH_DELAY = 250;
export const ANY_BRANCH = {
export const ALL_BRANCHES = {
id: null,
name: __('Any branch'),
name: __('All branches'),
};
export const EMPTY_STATUS_CHECK = {
......
import { __ } from '~/locale';
export const BRANCH_FETCH_DELAY = 250;
export const ANY_BRANCH = {
export const ALL_BRANCHES = {
id: null,
name: __('Any branch'),
name: __('All branches'),
};
......@@ -3,7 +3,7 @@ import { GlDropdown, GlDropdownItem, GlSearchBoxByType } from '@gitlab/ui';
import { debounce } from 'lodash';
import Api from 'ee/api';
import { __ } from '~/locale';
import { BRANCH_FETCH_DELAY, ANY_BRANCH } from './constants';
import { BRANCH_FETCH_DELAY, ALL_BRANCHES } from './constants';
export default {
components: {
......@@ -33,7 +33,7 @@ export default {
initialLoading: false,
searching: false,
searchTerm: '',
selected: this.selectedBranches[0] || ANY_BRANCH,
selected: this.selectedBranches[0] || ALL_BRANCHES,
};
},
mounted() {
......@@ -48,16 +48,16 @@ export default {
methods: {
fetchBranches(term) {
this.searching = true;
const excludeAnyBranch = term && !term.toLowerCase().includes('any');
const excludeAllBranches = term && !term.toLowerCase().includes('all');
return Api.projectProtectedBranches(this.projectId, term)
.then((branches) => {
this.$emit('apiError', { hasErrored: false });
this.branches = excludeAnyBranch ? branches : [ANY_BRANCH, ...branches];
this.branches = excludeAllBranches ? branches : [ALL_BRANCHES, ...branches];
})
.catch((error) => {
this.$emit('apiError', { hasErrored: true, error });
this.branches = excludeAnyBranch ? [] : [ANY_BRANCH];
this.branches = excludeAllBranches ? [] : [ALL_BRANCHES];
})
.finally(() => {
this.searching = false;
......
......@@ -22,9 +22,9 @@ describe('Rule Branches', () => {
wrapper = null;
});
it('displays "Any branch" if there are no protected branches', () => {
it('displays "All branches" if there are no protected branches', () => {
createComponent();
expect(wrapper.text()).toContain('Any branch');
expect(wrapper.text()).toContain('All branches');
});
it('displays the branch name of the first protected branch', () => {
......
......@@ -16,10 +16,10 @@ describe('Status checks branch', () => {
const findBranch = () => wrapper.find('span');
it('renders "Any branch" if no branch is given', () => {
it('renders "All branches" if no branch is given', () => {
createWrapper();
expect(findBranch().text()).toBe('Any branch');
expect(findBranch().text()).toBe('All branches');
expect(findBranch().classes('monospace')).toBe(true);
});
......
export const TEST_DEFAULT_BRANCH = { name: 'Any branch' };
export const TEST_DEFAULT_BRANCH = { name: 'All branches' };
export const TEST_PROJECT_ID = '1';
export const TEST_PROTECTED_BRANCHES = [
{ id: 1, name: 'main' },
......
......@@ -76,7 +76,7 @@ describe('Protected Branches Selector', () => {
).toBe(true);
});
it('displays all the protected branches and any branch', async () => {
it('displays all the protected branches and all branches', async () => {
createComponent();
await nextTick();
expect(findDropdown().props('loading')).toBe(true);
......@@ -97,7 +97,7 @@ describe('Protected Branches Selector', () => {
expect(wrapper.emitted('apiError')).toStrictEqual([[{ hasErrored: true, error }]]);
});
it('returns just the any branch dropdown items', () => {
it('returns just the all branch dropdown items', () => {
expect(findDropdownItems()).toHaveLength(1);
expect(findDropdownItems().at(0).text()).toBe(TEST_DEFAULT_BRANCH.name);
});
......@@ -126,15 +126,15 @@ describe('Protected Branches Selector', () => {
expect(findSearch().props('isLoading')).toBe(false);
});
it('fetches protected branches with no any branch if there is a search', async () => {
it('fetches protected branches with no all branches if there is a search', async () => {
findSearch().vm.$emit('input', 'main');
await waitForPromises();
expect(findDropdownItems()).toHaveLength(protectedBranchNames().length);
});
it('fetches protected branches with any branch if search contains term "any"', async () => {
findSearch().vm.$emit('input', 'any');
it('fetches protected branches with all branches if search contains term "all"', async () => {
findSearch().vm.$emit('input', 'all');
await waitForPromises();
expect(findDropdownItems()).toHaveLength(branchNames().length);
......@@ -160,10 +160,10 @@ describe('Protected Branches Selector', () => {
});
});
describe('when fetching the branch list fails while searching for the term "any"', () => {
describe('when fetching the branch list fails while searching for the term "all"', () => {
beforeEach(() => {
jest.spyOn(Api, 'projectProtectedBranches').mockRejectedValueOnce(error);
findSearch().vm.$emit('input', 'any');
findSearch().vm.$emit('input', 'all');
return waitForPromises();
});
......@@ -175,7 +175,7 @@ describe('Protected Branches Selector', () => {
]);
});
it('returns just the any branch dropdown item', () => {
it('returns just the all branch dropdown item', () => {
expect(findDropdownItems()).toHaveLength(1);
expect(findDropdownItems().at(0).text()).toBe(TEST_DEFAULT_BRANCH.name);
});
......
......@@ -3934,9 +3934,6 @@ msgstr ""
msgid "Any Milestone"
msgstr ""
msgid "Any branch"
msgstr ""
msgid "Any eligible user"
msgstr ""
......@@ -4121,7 +4118,7 @@ msgstr ""
msgid "Apply template"
msgstr ""
msgid "Apply this approval rule to any branch or a specific protected branch."
msgid "Apply this approval rule to all branches or a specific protected branch."
msgstr ""
msgid "Applying"
......@@ -32177,7 +32174,7 @@ msgstr ""
msgid "StatusCheck|An error occurred fetching the status checks."
msgstr ""
msgid "StatusCheck|Apply this status check to any branch or a specific protected branch."
msgid "StatusCheck|Apply this status check to all branches or a specific protected branch."
msgstr ""
msgid "StatusCheck|Check for a status response in Merge Requests. Failures do not block merges. %{link_start}Learn more%{link_end}."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment