Update default initial branch name in Frontend code (editor)
This issue is analogous to https://gitlab.com/gitlab-org/gitlab/-/issues/323925, only for Frontend code.
Problem to solve
As we work to Rename <code data-sourcepos="5:24-5:29">master</code> branch to <code data-sourcepos="5:43-5:46">main</code> branch in the GitLab project, Frontend code that references the old default initial branch name need to be updated (HAML files have already been covered by the Backend issue: https://gitlab.com/gitlab-org/gitlab/-/issues/323925). For example:
./app/assets/javascripts/static_site_editor/constants.js:export const DEFAULT_TARGET_BRANCH = 'master';
Proposal
The word master
is present in many places in the codebase. For 14.0 we are most interested in changing master
to main
only when it will break the application if master
is returned, eg: @project.default_branch || 'master'
.
The full objective of https://gitlab.com/groups/gitlab-org/-/epics/3600 is to completely remove the word master
from the codebase including method names, constants and in test data.
Work on this issue should produce:
- MRs to remove
master
where it will break the application when there is no longer amaster
branch - a follow-up issue to remove all of the other references, which will be scheduled at some point after %14.0
If it is just as easy to change the references as part of this issue, then go for it!
Initial scans
/app
.vue and .js files
grep -v -r --include=\*.js --include=\*.vue '^\s*\/\/\|^\s*\*' ./app | grep 'master'
./app/assets/javascripts/static_site_editor/constants.js:export const DEFAULT_TARGET_BRANCH = 'master';
./app/assets/javascripts/editor/extensions/editor_ci_schema_ext.js: registerCiSchema({ projectNamespace, projectPath, ref = 'master' } = {}) {
./app/assets/javascripts/ide/ide_router.js:/project/h5bp/html5-boilerplate/blob/master
./app/assets/javascripts/ide/ide_router.js:/project/h5bp/html5-boilerplate/blob/master/app/js/test.js
./app/assets/javascripts/ide/ide_router.js: redirect: (to) => joinPaths(to.path, '/master/-/'),
./app/assets/javascripts/ide/ide_router.js: redirect: (to) => joinPaths(to.path, '/edit/master/-/'),
./app/assets/javascripts/ide/lib/themes/dark.js:https://github.com/brijeshb42/monaco-themes/blob/master/themes/Tomorrow-Night.json
./app/assets/javascripts/ide/lib/themes/solarized_light.js:https://github.com/brijeshb42/monaco-themes/blob/master/themes/Solarized-dark.json
./app/assets/javascripts/ide/lib/themes/solarized_dark.js:https://github.com/brijeshb42/monaco-themes/blob/master/themes/Solarized-dark.json
./app/assets/javascripts/ide/lib/themes/monokai.js:https://github.com/brijeshb42/monaco-themes/blob/master/themes/Tomorrow-Night.json
./app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_identifier_instance_text.js: - `[an issue labelled `~"master:broken"`][broken-master-issues]`
./spec files
grep -r --include=\*.js master ./spec
./spec/frontend/static_site_editor/mock_data.js: web_url: '/tree/root-master-patch-88195',
./spec/frontend/static_site_editor/mock_data.js:export const branch = 'master';
./spec/frontend/static_site_editor/mock_data.js:export const baseUrl = '/user1/project1/-/sse/master%2Ftest.md';
./spec/frontend/static_site_editor/services/renderers/render_image_spec.js: ${'/relative/path/to/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/default/source/relative/path/to/image.png'}
./spec/frontend/static_site_editor/services/renderers/render_image_spec.js: ${'/target/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/source/with/target/image.png'}
./spec/frontend/static_site_editor/services/renderers/render_image_spec.js: ${'relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/relative/to/current/image.png'}
./spec/frontend/static_site_editor/services/renderers/render_image_spec.js: ${'./relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/./relative/to/current/image.png'}
./spec/frontend/static_site_editor/services/renderers/render_image_spec.js: ${'../relative/to/current/image.png'} | ${false} | ${'http://test.host/user1/project1/-/raw/master/../relative/to/current/image.png'}
./spec/frontend/ide/components/new_dropdown/index_spec.js: branch: 'master',
./spec/frontend/ide/components/ide_review_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/ide_review_spec.js: Vue.set(store.state.trees, 'abcproject/master', {
./spec/frontend/ide/components/ide_status_bar_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/ide_tree_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/ide_tree_spec.js: Vue.set(store.state.trees, 'abcproject/master', {
./spec/frontend/ide/components/commit_sidebar/new_merge_request_option_spec.js: const createComponent = ({ currentBranchId = 'master', createNewBranch = false } = {}) => {
./spec/frontend/ide/components/commit_sidebar/new_merge_request_option_spec.js: currentBranchId: 'master',
./spec/frontend/ide/components/commit_sidebar/new_merge_request_option_spec.js: currentBranchId: 'master',
./spec/frontend/ide/components/commit_sidebar/actions_spec.js:const BRANCH_DEFAULT = 'master';
./spec/frontend/ide/components/commit_sidebar/actions_spec.js: currentBranchId = 'master',
./spec/frontend/ide/components/commit_sidebar/actions_spec.js: expect(findText()).toContain('Commit to master branch');
./spec/frontend/ide/components/commit_sidebar/actions_spec.js: vm.$store.state.currentBranchId = 'master';
./spec/frontend/ide/components/commit_sidebar/actions_spec.js: expect(findText()).toContain('Commit to master branch');
./spec/frontend/ide/components/commit_sidebar/form_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/merge_requests/list_spec.js: currentProjectId: 'project/master',
./spec/frontend/ide/components/ide_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/ide_spec.js: store.state.trees['abcproject/master'] = {
./spec/frontend/ide/components/branches/item_spec.js: name: 'master',
./spec/frontend/ide/components/nav_dropdown_spec.js: currentBranchId: 'master',
./spec/frontend/ide/components/nav_dropdown_spec.js: master: { id: 'master' },
./spec/frontend/ide/components/repo_editor_spec.js: master: {
./spec/frontend/ide/components/repo_editor_spec.js: name: 'master',
./spec/frontend/ide/components/repo_editor_spec.js: currentBranchId: 'master',
./spec/frontend/ide/components/repo_commit_section_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/repo_commit_section_spec.js: master: {
./spec/frontend/ide/components/repo_commit_section_spec.js: store.state.currentBranch = 'master';
./spec/frontend/ide/components/ide_tree_list_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/components/ide_tree_list_spec.js: Vue.set(store.state.trees, 'abcproject/master', {
./spec/frontend/ide/components/ide_tree_list_spec.js: store.state.trees['abcproject/master'].loading = true;
./spec/frontend/ide/mock_data.js: master: {
./spec/frontend/ide/mock_data.js: treeId: 'abcproject/master',
./spec/frontend/ide/mock_data.js: default_branch: 'master',
./spec/frontend/ide/mock_data.js: ref: 'master',
./spec/frontend/ide/mock_data.js: ref: 'master',
./spec/frontend/ide/mock_data.js: name: 'master',
./spec/frontend/ide/mock_data.js: message: 'Update master branch',
./spec/frontend/ide/services/index_spec.js:const TEST_BRANCH = 'master-patch-123';
./spec/frontend/ide/utils_spec.js: * master-patch-22432 -> master-patch-22433
./spec/frontend/ide/utils_spec.js: ${'master-patch-22432'} | ${'master-patch-22433'}
./spec/frontend/ide/utils_spec.js: ${'master-patch-22432'} | ${'master-patch-39135'}
./spec/frontend/ide/ide_router_spec.js: `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob/`,
./spec/frontend/ide/ide_router_spec.js: `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob`,
./spec/frontend/ide/ide_router_spec.js: `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/tree/`,
./spec/frontend/ide/ide_router_spec.js: `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/blob`,
./spec/frontend/ide/ide_router_spec.js: `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/edit`,
./spec/frontend/ide/ide_router_spec.js: `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/merge_requests/2`,
./spec/frontend/ide/stores/actions/merge_request_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/actions/merge_request_spec.js: master: {
./spec/frontend/ide/stores/actions/file_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/actions/file_spec.js: expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/-/newOpenFile/');
./spec/frontend/ide/stores/actions/file_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/actions/file_spec.js: master: {
./spec/frontend/ide/stores/actions/file_spec.js: expect(document.title).toBe(`${localFile.path} · master · test/test · GitLab`);
./spec/frontend/ide/stores/actions/file_spec.js: expect(document.title).toBe(`new-shiny-file · master · test/test · GitLab`);
./spec/frontend/ide/stores/actions/file_spec.js: expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/-/tempFile/');
./spec/frontend/ide/stores/actions/file_spec.js: expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/');
./spec/frontend/ide/stores/actions/tree_spec.js: branch: 'master',
./spec/frontend/ide/stores/actions/tree_spec.js: branchId: 'master',
./spec/frontend/ide/stores/actions/tree_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/actions/tree_spec.js: projectTree = store.state.trees['abcproject/master'];
./spec/frontend/ide/stores/actions/tree_spec.js: 'master-testing': {
./spec/frontend/ide/stores/actions/tree_spec.js: findBranch: () => store.state.projects['abc/def'].branches['master-testing'],
./spec/frontend/ide/stores/actions/tree_spec.js: branchId: 'master-testing',
./spec/frontend/ide/stores/actions/tree_spec.js: actionPayload: { projectId: 'abc/def', branchId: 'master-testing' },
./spec/frontend/ide/stores/actions/tree_spec.js: store.state.trees['abcproject/master'] = {};
./spec/frontend/ide/stores/actions/tree_spec.js: { projectId: 'abcproject', branchId: 'master', treeList: [treeFile] },
./spec/frontend/ide/stores/actions/tree_spec.js: treePath: 'abcproject/master',
./spec/frontend/ide/stores/actions/project_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/actions/project_spec.js: master: {
./spec/frontend/ide/stores/actions/project_spec.js: expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'master');
./spec/frontend/ide/stores/actions/project_spec.js: branchId: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: text: "Branch <strong>master</strong> was not found in this project's repository.",
./spec/frontend/ide/stores/actions/project_spec.js: actionPayload: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: default_branch: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: ref: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: default_branch: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: default_branch: 'master',
./spec/frontend/ide/stores/actions/project_spec.js: { projectId: TEST_PROJECT_ID, branchId: 'master' },
./spec/frontend/ide/stores/actions/project_spec.js: { type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/master` } },
./spec/frontend/ide/stores/actions/project_spec.js: payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/master`], forceValue: false },
./spec/frontend/ide/stores/actions/project_spec.js: const trees = { [`${TEST_PROJECT_ID}/master`]: [] };
./spec/frontend/ide/stores/actions/project_spec.js: { projectId: TEST_PROJECT_ID, branchId: 'master' },
./spec/frontend/ide/stores/modules/commit/actions_spec.js: .onGet('/api/v1/projects/abcproject/repository/branches/master')
./spec/frontend/ide/stores/modules/commit/actions_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/modules/commit/actions_spec.js: const branch = 'master';
./spec/frontend/ide/stores/modules/commit/actions_spec.js: currentBranchId: 'master',
./spec/frontend/ide/stores/modules/commit/actions_spec.js: master: {
./spec/frontend/ide/stores/modules/commit/actions_spec.js: expect(store.state.projects.abcproject.branches.master.workingReference).toBe(data.id);
./spec/frontend/ide/stores/modules/commit/actions_spec.js: currentBranchId: 'master',
./spec/frontend/ide/stores/modules/commit/actions_spec.js: default_branch: 'master',
./spec/frontend/ide/stores/modules/commit/actions_spec.js: master: {
./spec/frontend/ide/stores/modules/commit/actions_spec.js: name: 'master',
./spec/frontend/ide/stores/modules/commit/actions_spec.js: `webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=master&nav_source=webide`,
./spec/frontend/ide/stores/modules/commit/getters_spec.js: currentBranchId: 'master',
./spec/frontend/ide/stores/modules/commit/getters_spec.js: expect(getters.branchName(state, localGetters, rootState)).toBe('master');
./spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js:const TEST_BRANCH_ID = 'master';
./spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js:const TEST_BRANCH_ID = 'master';
./spec/frontend/ide/stores/mutations_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/mutations_spec.js: localState.trees['gitlab-ce/master'] = {
./spec/frontend/ide/stores/mutations_spec.js: expect(localState.trees['gitlab-ce/master'].tree.length).toEqual(1);
./spec/frontend/ide/stores/mutations_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/mutations_spec.js: localState.trees['gitlab-ce/master'] = {
./spec/frontend/ide/stores/mutations_spec.js: localState.trees['gitlab-ce/master'].tree.push(localState.entries.filePath);
./spec/frontend/ide/stores/mutations_spec.js: expect(localState.trees['gitlab-ce/master'].tree).toEqual([]);
./spec/frontend/ide/stores/mutations_spec.js: 'gitlab-ce/master': {
./spec/frontend/ide/stores/mutations_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/mutations_spec.js: localState.trees['gitlab-ce/master'].tree = [alpha, beta, gamma];
./spec/frontend/ide/stores/mutations_spec.js: expect(localState.trees['gitlab-ce/master'].tree).toEqual([
./spec/frontend/ide/stores/mutations/branch_spec.js: mutations.SET_CURRENT_BRANCH(localState, 'master');
./spec/frontend/ide/stores/mutations/branch_spec.js: expect(localState.currentBranchId).toBe('master');
./spec/frontend/ide/stores/mutations/branch_spec.js: master: {},
./spec/frontend/ide/stores/mutations/branch_spec.js: branchId: 'master',
./spec/frontend/ide/stores/mutations/branch_spec.js: expect(localState.projects.Example.branches.master.commit.title).toBe('Example commit');
./spec/frontend/ide/stores/mutations/file_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/mutations/file_spec.js: localState.trees['gitlab-ce/master'] = {
./spec/frontend/ide/stores/mutations/file_spec.js: expect(localState.trees['gitlab-ce/master'].tree).toEqual([{ ...localFile, deleted: false }]);
./spec/frontend/ide/stores/mutations/tree_spec.js: localState.trees['project/master'] = {
./spec/frontend/ide/stores/mutations/tree_spec.js: treePath: 'project/master',
./spec/frontend/ide/stores/mutations/tree_spec.js: const tree = localState.trees['project/master'];
./spec/frontend/ide/stores/mutations/tree_spec.js: treePath: 'project/master',
./spec/frontend/ide/stores/mutations/tree_spec.js: treePath: 'project/master',
./spec/frontend/ide/stores/mutations/tree_spec.js: expect(localState.trees['project/master'].loading).toBe(true);
./spec/frontend/ide/stores/mutations/tree_spec.js: localState.trees['project/master'] = {
./spec/frontend/ide/stores/mutations/tree_spec.js: treePath: 'project/master',
./spec/frontend/ide/stores/mutations/tree_spec.js: const { tree } = localState.trees['project/master'];
./spec/frontend/ide/stores/mutations/tree_spec.js: localState.trees['project/master'] = {
./spec/frontend/ide/stores/mutations/tree_spec.js: treePath: 'project/master',
./spec/frontend/ide/stores/mutations/tree_spec.js: const { tree } = localState.trees['project/master'];
./spec/frontend/ide/stores/utils_spec.js: currentBranchId: 'master',
./spec/frontend/ide/stores/utils_spec.js: expect(document.title).toBe('README.md · master · test/test · GitLab');
./spec/frontend/ide/stores/utils_spec.js: currentBranchId: 'master',
./spec/frontend/ide/stores/utils_spec.js: branch: 'master',
./spec/frontend/ide/stores/utils_spec.js: branch: 'master',
./spec/frontend/ide/stores/utils_spec.js: currentBranchId: 'master',
./spec/frontend/ide/stores/utils_spec.js: branch: 'master',
./spec/frontend/ide/stores/utils_spec.js: branch: 'master',
./spec/frontend/ide/stores/utils_spec.js: const currentBranchId = 'master';
./spec/frontend/ide/stores/actions_spec.js: store.state.currentBranchId = 'master';
./spec/frontend/ide/stores/actions_spec.js: expect(router.push).toHaveBeenCalledWith(`/project/test/test/tree/master/-/renamed/`);
./spec/frontend/ide/stores/actions_spec.js: branchId: 'master-testing',
./spec/frontend/ide/stores/getters_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/getters_spec.js: master: {
./spec/frontend/ide/stores/getters_spec.js: name: 'master',
./spec/frontend/ide/stores/getters_spec.js: expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'master');
./spec/frontend/ide/stores/getters_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/getters_spec.js: master: {
./spec/frontend/ide/stores/getters_spec.js: name: 'master',
./spec/frontend/ide/stores/getters_spec.js: result = getters.findBranch(localState, localGetters)('abcproject', 'master');
./spec/frontend/ide/stores/getters_spec.js: expect(result.name).toBe('master');
./spec/frontend/ide/stores/getters_spec.js: default_branch: 'master',
./spec/frontend/ide/stores/getters_spec.js: branchName: 'master',
./spec/frontend/ide/stores/getters_spec.js: default_branch: 'master',
./spec/frontend/ide/stores/getters_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/getters_spec.js: `/project/test/test/tree/master/-/path/to/foo/bar-1.jpg/`,
./spec/frontend/ide/stores/getters_spec.js: localState.currentBranchId = 'master';
./spec/frontend/ide/stores/getters_spec.js: uri: `${TEST_HOST}/path/to/some/project/-/schema/master/.gitlab-ci.yml`,
./spec/frontend/ide/stores/getters_spec.js: master: {
./spec/frontend/ide/stores/getters_spec.js: name: 'master',
./spec/frontend/vue_shared/components/web_ide_link_spec.js:const TEST_EDIT_URL = '/gitlab-test/test/-/edit/master/';
./spec/frontend/vue_shared/components/web_ide_link_spec.js:const TEST_WEB_IDE_URL = '/-/ide/project/gitlab-test/test/edit/master/-/';
./spec/frontend_integration/ide/helpers/start.js: const pathSuffix = mrId ? `merge_requests/${mrId}` : `tree/master/-/${path}`;
./spec/frontend_integration/ide/ide_integration_spec.js: expect(mockServer.db.branches.findBy({ name: 'master' }).commit).toMatchObject({
./spec/frontend_integration/ide/ide_integration_spec.js: expect(window.location.pathname).toBe('/-/ide/project/gitlab-test/lorem-ipsum/tree/master/-/');
./spec/frontend_integration/ide/user_opens_ide_spec.js: it('shows branch/MR dropdown with master selected', async () => {
./spec/frontend_integration/ide/user_opens_ide_spec.js: expect(dropdown.textContent).toContain('master');
.scss files
grep -r --include=\*.scss master ./app
./app/assets/stylesheets/components/rich_content_editor.scss:* https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/master/source/stylesheets/_base.scss#L977
locale
After updating the frontend code and updating the locale strings, this number should be zero or close to it.
grep -r --include=\* master ./app/assets/javascripts/locale/ | wc -l
64