Commit 8e3d3e49 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '326997-master-to-main-ide' into 'master'

Update default initial branch name in group::editor code[RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!63879
parents 045c11d1 4869b29d
......@@ -112,3 +112,5 @@ export const LIVE_PREVIEW_DEBOUNCE = 2000;
// This is the maximum number of files to auto open when opening the Web IDE
// from a merge request
export const MAX_MR_FILES_AUTO_OPEN = 10;
export const DEFAULT_BRANCH = 'main';
......@@ -16,8 +16,8 @@ Vue.use(IdeRouter);
/**
* Routes below /-/ide/:
/project/h5bp/html5-boilerplate/blob/master
/project/h5bp/html5-boilerplate/blob/master/app/js/test.js
/project/h5bp/html5-boilerplate/blob/main
/project/h5bp/html5-boilerplate/blob/main/app/js/test.js
/project/h5bp/html5-boilerplate/mr/123
/project/h5bp/html5-boilerplate/mr/123/app/js/test.js
......@@ -39,7 +39,7 @@ const EmptyRouterComponent = {
},
};
export const createRouter = (store) => {
export const createRouter = (store, defaultBranch) => {
const router = new IdeRouter({
mode: 'history',
base: joinPaths(gon.relative_url_root || '', '/-/ide/'),
......@@ -58,7 +58,7 @@ export const createRouter = (store) => {
},
{
path: ':targetmode(edit|tree|blob)',
redirect: (to) => joinPaths(to.path, '/master/-/'),
redirect: (to) => joinPaths(to.path, `/${defaultBranch}/-/`),
},
{
path: 'merge_requests/:mrid',
......@@ -66,7 +66,7 @@ export const createRouter = (store) => {
},
{
path: '',
redirect: (to) => joinPaths(to.path, '/edit/master/-/'),
redirect: (to) => joinPaths(to.path, `/edit/${defaultBranch}/-/`),
},
],
},
......
import { identity } from 'lodash';
import Vue from 'vue';
import { mapActions } from 'vuex';
import { DEFAULT_BRANCH } from '~/ide/constants';
import PerformancePlugin from '~/performance/vue_performance_plugin';
import Translate from '~/vue_shared/translate';
import { parseBoolean } from '../lib/utils/common_utils';
......@@ -38,7 +39,7 @@ export function initIde(el, options = {}) {
const { rootComponent = ide, extendStore = identity } = options;
const store = createStore();
const router = createRouter(store);
const router = createRouter(store, el.dataset.defaultBranch || DEFAULT_BRANCH);
return new Vue({
el,
......
......@@ -146,7 +146,7 @@ export function getFileEOL(content = '') {
* hello.md -> hello-1.md
* hello_2.md -> hello_3.md
* hello_ -> hello_1
* master-patch-22432 -> master-patch-22433
* main-patch-22432 -> main-patch-22433
* patch_332 -> patch_333
*
* @param {string} filename File name or branch name
......
......@@ -4,7 +4,7 @@ import { buildTextToken, buildUneditableInlineTokens } from './build_uneditable_
Use case examples:
- Majority: two bracket pairs, back-to-back, each with content (including spaces)
- `[environment terraform plans][terraform]`
- `[an issue labelled `~"master:broken"`][broken-master-issues]`
- `[an issue labelled `~"main:broken"`][broken-main-issues]`
- Minority: two bracket pairs the latter being empty or only one pair with content (including spaces)
- `[this link][]`
- `[this link]`
......
......@@ -47,7 +47,7 @@
/**
* Styling below ensures that YouTube videos are displayed in the editor the same as they would in about.gitlab.com
* https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/master/source/stylesheets/_base.scss#L977
* https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/main/source/stylesheets/_base.scss#L977
*/
.video_container {
padding-bottom: 56.25%;
......
......@@ -14,6 +14,7 @@ module IdeHelper
'render-whitespace-in-code': current_user.render_whitespace_in_code.to_s,
'codesandbox-bundler-url': Gitlab::CurrentSettings.web_ide_clientside_preview_bundler_url,
'branch-name' => @branch,
'default-branch' => @project && @project.default_branch,
'file-path' => @path,
'merge-request' => @merge_request,
'fork-info' => @fork_info&.to_json,
......
......@@ -7,7 +7,7 @@ import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
import { projectData } from '../../mock_data';
const TEST_BRANCH = {
name: 'master',
name: 'main',
committedDate: '2018-01-05T05:50Z',
};
const TEST_PROJECT_ID = projectData.name_with_namespace;
......
......@@ -10,7 +10,7 @@ import {
const ACTION_UPDATE_COMMIT_ACTION = 'commit/updateCommitAction';
const BRANCH_DEFAULT = 'master';
const BRANCH_DEFAULT = 'main';
const BRANCH_PROTECTED = 'protected/access';
const BRANCH_PROTECTED_NO_ACCESS = 'protected/no-access';
const BRANCH_REGULAR = 'regular';
......@@ -20,11 +20,7 @@ describe('IDE commit sidebar actions', () => {
let store;
let vm;
const createComponent = ({
hasMR = false,
currentBranchId = 'master',
emptyRepo = false,
} = {}) => {
const createComponent = ({ hasMR = false, currentBranchId = 'main', emptyRepo = false } = {}) => {
const Component = Vue.extend(commitActions);
vm = createComponentWithStore(Component, store);
......@@ -72,7 +68,7 @@ describe('IDE commit sidebar actions', () => {
it('renders current branch text', () => {
createComponent();
expect(findText()).toContain('Commit to master branch');
expect(findText()).toContain('Commit to main branch');
});
it('hides merge request option when project merge requests are disabled', (done) => {
......@@ -112,7 +108,7 @@ describe('IDE commit sidebar actions', () => {
it('calls again after staged changes', (done) => {
createComponent({ currentBranchId: null });
vm.$store.state.currentBranchId = 'master';
vm.$store.state.currentBranchId = 'main';
vm.$store.state.changedFiles.push({});
vm.$store.state.stagedFiles.push({});
......@@ -158,7 +154,7 @@ describe('IDE commit sidebar actions', () => {
it('only renders commit to current branch', () => {
expect(findRadios().length).toBe(1);
expect(findText()).toContain('Commit to master branch');
expect(findText()).toContain('Commit to main branch');
});
});
});
......@@ -67,7 +67,7 @@ describe('IDE commit form', () => {
store = createStore();
store.state.stagedFiles.push('test');
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
Vue.set(store.state.projects, 'abcproject', {
...projectData,
userPermissions: { pushCode: true },
......
......@@ -24,7 +24,7 @@ describe('create new MR checkbox', () => {
store.state.projects[store.state.currentProjectId].userPermissions = permissions;
};
const createComponent = ({ currentBranchId = 'master', createNewBranch = false } = {}) => {
const createComponent = ({ currentBranchId = 'main', createNewBranch = false } = {}) => {
const Component = Vue.extend(NewMergeRequestOption);
vm = createComponentWithStore(Component, store);
......@@ -63,7 +63,7 @@ describe('create new MR checkbox', () => {
describe('is rendered when pushing to a new branch', () => {
beforeEach(() => {
createComponent({
currentBranchId: 'master',
currentBranchId: 'main',
createNewBranch: true,
});
});
......@@ -87,7 +87,7 @@ describe('create new MR checkbox', () => {
describe('is NOT rendered when pushing to the same branch', () => {
beforeEach(() => {
createComponent({
currentBranchId: 'master',
currentBranchId: 'main',
createNewBranch: false,
});
});
......
......@@ -19,9 +19,9 @@ describe('IDE review mode', () => {
beforeEach(() => {
store = createStore();
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', {
Vue.set(store.state.trees, 'abcproject/main', {
tree: [file('fileName')],
loading: false,
});
......
......@@ -22,9 +22,9 @@ describe('WebIDE', () => {
const createComponent = ({ projData = emptyProjData, state = {} } = {}) => {
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects.abcproject = projData && { ...projData };
store.state.trees['abcproject/master'] = {
store.state.trees['abcproject/main'] = {
tree: [],
loading: false,
};
......
......@@ -24,7 +24,7 @@ describe('ideStatusBar', () => {
store = createStore();
store.state.currentProjectId = TEST_PROJECT_ID;
store.state.projects[TEST_PROJECT_ID] = _.clone(projectData);
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
});
afterEach(() => {
......
......@@ -14,9 +14,9 @@ describe('IDE tree list', () => {
const bootstrapWithTree = (tree = normalBranchTree) => {
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', {
Vue.set(store.state.trees, 'abcproject/main', {
tree,
loading: false,
});
......@@ -42,7 +42,7 @@ describe('IDE tree list', () => {
});
it('renders loading indicator', (done) => {
store.state.trees['abcproject/master'].loading = true;
store.state.trees['abcproject/main'].loading = true;
vm.$nextTick(() => {
expect(vm.$el.querySelector('.multi-file-loading-container')).not.toBeNull();
......
......@@ -18,9 +18,9 @@ describe('IdeTree', () => {
store = createStore();
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', {
Vue.set(store.state.trees, 'abcproject/main', {
tree: [file('fileName')],
loading: false,
});
......
......@@ -21,7 +21,7 @@ describe('IDE merge requests list', () => {
const fakeStore = new Vuex.Store({
state: {
currentMergeRequestId: '1',
currentProjectId: 'project/master',
currentProjectId: 'project/main',
...restOfState,
},
modules: {
......
......@@ -14,14 +14,14 @@ describe('IDE NavDropdown', () => {
store = createStore();
Object.assign(store.state, {
currentProjectId: TEST_PROJECT_ID,
currentBranchId: 'master',
currentBranchId: 'main',
projects: {
[TEST_PROJECT_ID]: {
userPermissions: {
[PERMISSION_READ_MR]: true,
},
branches: {
master: { id: 'master' },
main: { id: 'main' },
},
},
},
......
......@@ -13,7 +13,7 @@ describe('new dropdown component', () => {
const component = Vue.extend(newDropdown);
vm = createComponentWithStore(component, store, {
branch: 'master',
branch: 'main',
path: '',
mouseOver: false,
type: 'tree',
......
......@@ -22,11 +22,11 @@ describe('RepoCommitSection', () => {
store.state.noChangesStateSvgPath = 'svg';
store.state.committedStateSvgPath = 'commitsvg';
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects.abcproject = {
web_url: '',
branches: {
master: {
main: {
workingReference: '1',
},
},
......@@ -39,7 +39,7 @@ describe('RepoCommitSection', () => {
}),
);
store.state.currentBranch = 'master';
store.state.currentBranch = 'main';
store.state.changedFiles = [];
store.state.stagedFiles = [{ ...files[0] }, { ...files[1] }];
store.state.stagedFiles.forEach((f) =>
......
......@@ -63,8 +63,8 @@ const prepareStore = (state, activeFile) => {
projects: {
'gitlab-org/gitlab': {
branches: {
master: {
name: 'master',
main: {
name: 'main',
commit: {
id: 'abcdefgh',
},
......@@ -73,7 +73,7 @@ const prepareStore = (state, activeFile) => {
},
},
currentProjectId: 'gitlab-org/gitlab',
currentBranchId: 'master',
currentBranchId: 'main',
entries: {
[activeFile.path]: activeFile,
},
......
......@@ -18,14 +18,14 @@ describe('IDE router', () => {
});
[
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/main/-/src/blob/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/main/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/tree/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/main/-/src/tree/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/weird:branch/name-123/-/src/tree/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/edit`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/merge_requests/2`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/main/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/main/-/src/edit`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/main/-/src/merge_requests/2`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/blob/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit/blob/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/merge_requests/2`,
......
......@@ -8,8 +8,8 @@ export const projectData = {
path: '',
name_with_namespace: 'namespace/abcproject',
branches: {
master: {
treeId: 'abcproject/master',
main: {
treeId: 'abcproject/main',
can_push: true,
commit: {
id: '123',
......@@ -19,13 +19,13 @@ export const projectData = {
mergeRequests: {},
merge_requests_enabled: true,
userPermissions: {},
default_branch: 'master',
default_branch: 'main',
};
export const pipelines = [
{
id: 1,
ref: 'master',
ref: 'main',
sha: '123',
details: {
status: {
......@@ -38,7 +38,7 @@ export const pipelines = [
},
{
id: 2,
ref: 'master',
ref: 'main',
sha: '213',
details: {
status: {
......@@ -178,9 +178,9 @@ export const mergeRequests = [
export const branches = [
{
id: 1,
name: 'master',
name: 'main',
commit: {
message: 'Update master branch',
message: 'Update main branch',
committed_date: '2018-08-01T00:20:05Z',
},
can_push: true,
......
......@@ -15,7 +15,7 @@ jest.mock('~/ide/services/gql');
const TEST_NAMESPACE = 'alice';
const TEST_PROJECT = 'wonderland';
const TEST_PROJECT_ID = `${TEST_NAMESPACE}/${TEST_PROJECT}`;
const TEST_BRANCH = 'master-patch-123';
const TEST_BRANCH = 'main-patch-123';
const TEST_COMMIT_SHA = '123456789';
const TEST_FILE_PATH = 'README2.md';
const TEST_FILE_OLD_PATH = 'OLD_README2.md';
......
......@@ -29,7 +29,7 @@ describe('IDE store file actions', () => {
store = createStore();
store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
router = createRouter(store);
......@@ -85,7 +85,7 @@ describe('IDE store file actions', () => {
.dispatch('closeFile', localFile)
.then(Vue.nextTick)
.then(() => {
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/-/newOpenFile/');
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/main/-/newOpenFile/');
});
});
......@@ -177,11 +177,11 @@ describe('IDE store file actions', () => {
store.state.entries[localFile.path] = localFile;
store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects['test/test'] = {
branches: {
master: {
main: {
commit: {
id: '7297abc',
},
......@@ -260,7 +260,7 @@ describe('IDE store file actions', () => {
it('sets document title with the branchId', () => {
return store.dispatch('getFileData', { path: localFile.path }).then(() => {
expect(document.title).toBe(`${localFile.path} · master · test/test · GitLab`);
expect(document.title).toBe(`${localFile.path} · main · test/test · GitLab`);
});
});
......@@ -329,7 +329,7 @@ describe('IDE store file actions', () => {
it('sets document title considering `prevPath` on a file', () => {
return store.dispatch('getFileData', { path: localFile.path }).then(() => {
expect(document.title).toBe(`new-shiny-file · master · test/test · GitLab`);
expect(document.title).toBe(`new-shiny-file · main · test/test · GitLab`);
});
});
});
......@@ -702,7 +702,7 @@ describe('IDE store file actions', () => {
});
it('pushes route for active file', () => {
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/-/tempFile/');
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/main/-/tempFile/');
});
});
});
......@@ -778,7 +778,7 @@ describe('IDE store file actions', () => {
it('pushes router URL when added', () => {
return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then(() => {
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/');
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/main/');
});
});
});
......
......@@ -463,11 +463,11 @@ describe('IDE store merge request actions', () => {
};
store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects['test/test'] = {
branches: {
master: {
main: {
commit: {
id: '7297abc',
},
......
......@@ -37,11 +37,11 @@ describe('IDE store project actions', () => {
describe('refreshLastCommitData', () => {
beforeEach(() => {
store.state.currentProjectId = 'abc/def';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects['abc/def'] = {
id: 4,
branches: {
master: {
main: {
commit: null,
},
},
......@@ -60,7 +60,7 @@ describe('IDE store project actions', () => {
branchId: store.state.currentBranchId,
})
.then(() => {
expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'master');
expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'main');
done();
})
......@@ -81,7 +81,7 @@ describe('IDE store project actions', () => {
type: 'SET_BRANCH_COMMIT',
payload: {
projectId: TEST_PROJECT_ID,
branchId: 'master',
branchId: 'main',
commit: { id: '123' },
},
},
......@@ -97,17 +97,17 @@ describe('IDE store project actions', () => {
it('dispatches setErrorMessage', (done) => {
testAction(
showBranchNotFoundError,
'master',
'main',
null,
[],
[
{
type: 'setErrorMessage',
payload: {
text: "Branch <strong>master</strong> was not found in this project's repository.",
text: "Branch <strong>main</strong> was not found in this project's repository.",
action: expect.any(Function),
actionText: 'Create branch',
actionPayload: 'master',
actionPayload: 'main',
},
},
],
......@@ -131,7 +131,7 @@ describe('IDE store project actions', () => {
},
getters: {
currentProject: {
default_branch: 'master',
default_branch: 'main',
},
},
dispatch() {},
......@@ -140,7 +140,7 @@ describe('IDE store project actions', () => {
)
.then(() => {
expect(api.createBranch).toHaveBeenCalledWith('project-path', {
ref: 'master',
ref: 'main',
branch: 'new-branch-name',
});
})
......@@ -158,7 +158,7 @@ describe('IDE store project actions', () => {
},
getters: {
currentProject: {
default_branch: 'master',
default_branch: 'main',
},
},
dispatch: dispatchSpy,
......@@ -180,7 +180,7 @@ describe('IDE store project actions', () => {
},
getters: {
currentProject: {
default_branch: 'master',
default_branch: 'main',
},
},
dispatch() {},
......@@ -199,13 +199,13 @@ describe('IDE store project actions', () => {
it('creates a blank tree and sets loading state to false', (done) => {
testAction(
loadEmptyBranch,
{ projectId: TEST_PROJECT_ID, branchId: 'master' },
{ projectId: TEST_PROJECT_ID, branchId: 'main' },
store.state,
[
{ type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/master` } },
{ type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/main` } },
{
type: 'TOGGLE_LOADING',
payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/master`], forceValue: false },
payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/main`], forceValue: false },
},
],
expect.any(Object),
......@@ -214,11 +214,11 @@ describe('IDE store project actions', () => {
});
it('does nothing, if tree already exists', (done) => {
const trees = { [`${TEST_PROJECT_ID}/master`]: [] };
const trees = { [`${TEST_PROJECT_ID}/main`]: [] };
testAction(
loadEmptyBranch,
{ projectId: TEST_PROJECT_ID, branchId: 'master' },
{ projectId: TEST_PROJECT_ID, branchId: 'main' },
{ trees },
[],
[],
......
......@@ -18,8 +18,8 @@ describe('Multi-file store tree actions', () => {
const basicCallParameters = {
endpoint: 'rootEndpoint',
projectId: 'abcproject',
branch: 'master',
branchId: 'master',
branch: 'main',
branchId: 'main',
ref: '12345678',
};
......@@ -31,7 +31,7 @@ describe('Multi-file store tree actions', () => {
mock = new MockAdapter(axios);
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
store.state.projects.abcproject = {
web_url: '',
path_with_namespace: 'foo/abcproject',
......@@ -66,7 +66,7 @@ describe('Multi-file store tree actions', () => {
store
.dispatch('getFiles', basicCallParameters)
.then(() => {
projectTree = store.state.trees['abcproject/master'];
projectTree = store.state.trees['abcproject/main'];
expect(projectTree.tree.length).toBe(2);
expect(projectTree.tree[0].type).toBe('tree');
......@@ -89,7 +89,7 @@ describe('Multi-file store tree actions', () => {
'abc/def': {
web_url: `${TEST_HOST}/files`,
branches: {
'master-testing': {
'main-testing': {
commit: {
id: '12345',
},
......@@ -98,7 +98,7 @@ describe('Multi-file store tree actions', () => {
},
};
const getters = {
findBranch: () => store.state.projects['abc/def'].branches['master-testing'],
findBranch: () => store.state.projects['abc/def'].branches['main-testing'],
};
mock.onGet(/(.*)/).replyOnce(500);
......@@ -112,7 +112,7 @@ describe('Multi-file store tree actions', () => {
},
{
projectId: 'abc/def',
branchId: 'master-testing',
branchId: 'main-testing',
},
)
.then(done.fail)
......@@ -121,7 +121,7 @@ describe('Multi-file store tree actions', () => {
text: 'An error occurred while loading all the files.',
action: expect.any(Function),
actionText: 'Please try again',
actionPayload: { projectId: 'abc/def', branchId: 'master-testing' },
actionPayload: { projectId: 'abc/def', branchId: 'main-testing' },
});
done();
});
......@@ -178,17 +178,17 @@ describe('Multi-file store tree actions', () => {
describe('setDirectoryData', () => {
it('sets tree correctly if there are no opened files yet', (done) => {
const treeFile = file({ name: 'README.md' });
store.state.trees['abcproject/master'] = {};
store.state.trees['abcproject/main'] = {};
testAction(
setDirectoryData,
{ projectId: 'abcproject', branchId: 'master', treeList: [treeFile] },
{ projectId: 'abcproject', branchId: 'main', treeList: [treeFile] },
store.state,
[
{
type: types.SET_DIRECTORY_DATA,
payload: {
treePath: 'abcproject/master',
treePath: 'abcproject/main',
data: [treeFile],
},
},
......
......@@ -777,7 +777,7 @@ describe('Multi-file store actions', () => {
it('routes to the renamed file if the original file has been opened', (done) => {
store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
Object.assign(store.state.entries.orig, {
opened: true,
......@@ -790,7 +790,7 @@ describe('Multi-file store actions', () => {
})
.then(() => {
expect(router.push.mock.calls).toHaveLength(1);
expect(router.push).toHaveBeenCalledWith(`/project/test/test/tree/master/-/renamed/`);
expect(router.push).toHaveBeenCalledWith(`/project/test/test/tree/main/-/renamed/`);
})
.then(done)
.catch(done.fail);
......@@ -1019,7 +1019,7 @@ describe('Multi-file store actions', () => {
},
{
projectId: 'abc/def',
branchId: 'master-testing',
branchId: 'main-testing',
},
];
dispatch = jest.fn();
......
......@@ -209,12 +209,12 @@ describe('IDE store getters', () => {
describe('currentBranch', () => {
it('returns current projects branch', () => {
localState.currentProjectId = 'abcproject';
localState.currentBranchId = 'master';
localState.currentBranchId = 'main';
localState.projects.abcproject = {
name: 'abcproject',
branches: {
master: {
name: 'master',
main: {
name: 'main',
},
},
};
......@@ -223,7 +223,7 @@ describe('IDE store getters', () => {
};
getters.currentBranch(localState, localGetters);
expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'master');
expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'main');
});
});
......@@ -243,12 +243,12 @@ describe('IDE store getters', () => {
it('returns the selected branch from a project', () => {
localState.currentProjectId = 'abcproject';
localState.currentBranchId = 'master';
localState.currentBranchId = 'main';
localState.projects.abcproject = {
name: 'abcproject',
branches: {
master: {
name: 'master',
main: {
name: 'main',
},
},
};
......@@ -256,9 +256,9 @@ describe('IDE store getters', () => {
findProject: () => localState.projects.abcproject,
};
result = getters.findBranch(localState, localGetters)('abcproject', 'master');
result = getters.findBranch(localState, localGetters)('abcproject', 'main');
expect(result.name).toBe('master');
expect(result.name).toBe('main');
});
});
......@@ -274,9 +274,9 @@ describe('IDE store getters', () => {
it("returns true when project's default branch matches current branch", () => {
const localGetters = {
currentProject: {
default_branch: 'master',
default_branch: 'main',
},
branchName: 'master',
branchName: 'main',
};
expect(getters.isOnDefaultBranch({}, localGetters)).toBeTruthy();
......@@ -285,7 +285,7 @@ describe('IDE store getters', () => {
it("returns false when project's default branch doesn't match current branch", () => {
const localGetters = {
currentProject: {
default_branch: 'master',
default_branch: 'main',
},
branchName: 'feature',
};
......@@ -620,10 +620,10 @@ describe('IDE store getters', () => {
describe('getUrlForPath', () => {
it('returns a route url for the given path', () => {
localState.currentProjectId = 'test/test';
localState.currentBranchId = 'master';
localState.currentBranchId = 'main';
expect(localStore.getters.getUrlForPath('path/to/foo/bar-1.jpg')).toBe(
`/project/test/test/tree/master/-/path/to/foo/bar-1.jpg/`,
`/project/test/test/tree/main/-/path/to/foo/bar-1.jpg/`,
);
});
});
......@@ -631,13 +631,13 @@ describe('IDE store getters', () => {
describe('getJsonSchemaForPath', () => {
beforeEach(() => {
localState.currentProjectId = 'path/to/some/project';
localState.currentBranchId = 'master';
localState.currentBranchId = 'main';
});
it('returns a json schema uri and match config for a json/yaml file that can be loaded by monaco', () => {
expect(localStore.getters.getJsonSchemaForPath('.gitlab-ci.yml')).toEqual({
fileMatch: ['*.gitlab-ci.yml'],
uri: `${TEST_HOST}/path/to/some/project/-/schema/master/.gitlab-ci.yml`,
uri: `${TEST_HOST}/path/to/some/project/-/schema/main/.gitlab-ci.yml`,
});
});
......@@ -645,8 +645,8 @@ describe('IDE store getters', () => {
localState.projects['path/to/some/project'] = {
name: 'project',
branches: {
master: {
name: 'master',
main: {
name: 'main',
commit: {
id: 'abcdef123456',
},
......
......@@ -47,7 +47,7 @@ describe('IDE commit module actions', () => {
jest.spyOn(router, 'push').mockImplementation();
mock
.onGet('/api/v1/projects/abcproject/repository/branches/master')
.onGet('/api/v1/projects/abcproject/repository/branches/main')
.reply(200, { commit: COMMIT_RESPONSE });
});
......@@ -101,7 +101,7 @@ describe('IDE commit module actions', () => {
originalGon = window.gon;
window.gon = { current_username: 'johndoe' };
store.state.currentBranchId = 'master';
store.state.currentBranchId = 'main';
});
afterEach(() => {
......@@ -177,7 +177,7 @@ describe('IDE commit module actions', () => {
committed_date: '123',
committer_name: 'root',
};
const branch = 'master';
const branch = 'main';
let f;
beforeEach(() => {
......@@ -192,12 +192,12 @@ describe('IDE commit module actions', () => {
Object.assign(store.state, {
currentProjectId: 'abcproject',
currentBranchId: 'master',
currentBranchId: 'main',
projects: {
abcproject: {
web_url: 'web_url',
branches: {
master: {
main: {
workingReference: '',
commit: {
short_id: TEST_COMMIT_SHA,
......@@ -228,7 +228,7 @@ describe('IDE commit module actions', () => {
branch,
})
.then(() => {
expect(store.state.projects.abcproject.branches.master.workingReference).toBe(data.id);
expect(store.state.projects.abcproject.branches.main.workingReference).toBe(data.id);
})
.then(done)
.catch(done.fail);
......@@ -310,14 +310,14 @@ describe('IDE commit module actions', () => {
changedFiles: [f],
openFiles: [f],
currentProjectId: 'abcproject',
currentBranchId: 'master',
currentBranchId: 'main',
projects: {
abcproject: {
default_branch: 'master',
default_branch: 'main',
web_url: 'webUrl',
branches: {
master: {
name: 'master',
main: {
name: 'main',
workingReference: '1',
commit: {
id: TEST_COMMIT_SHA,
......@@ -460,7 +460,7 @@ describe('IDE commit module actions', () => {
.dispatch('commit/commitChanges')
.then(() => {
expect(visitUrl).toHaveBeenCalledWith(
`webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=master&nav_source=webide`,
`webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=main&nav_source=webide`,
);
done();
......
......@@ -46,7 +46,7 @@ describe('IDE commit module getters', () => {
describe('branchName', () => {
const rootState = {
currentBranchId: 'master',
currentBranchId: 'main',
};
const localGetters = {
placeholderBranchName: 'placeholder-branch-name',
......@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => {
it('defaults to currentBranchId when not committing to a new branch', () => {
localGetters.isCreatingNewBranch = false;
expect(getters.branchName(state, localGetters, rootState)).toBe('master');
expect(getters.branchName(state, localGetters, rootState)).toBe('main');
});
describe('commit to a new branch', () => {
......
......@@ -13,7 +13,7 @@ import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status';
const TEST_PROJECT_PATH = 'lorem/root';
const TEST_BRANCH_ID = 'master';
const TEST_BRANCH_ID = 'main';
const TEST_YAML_HELP_PATH = `${TEST_HOST}/test/yaml/help`;
const TEST_RUNNERS_HELP_PATH = `${TEST_HOST}/test/runners/help`;
......
......@@ -11,7 +11,7 @@ import httpStatus from '~/lib/utils/http_status';
jest.mock('~/flash');
const TEST_PROJECT_PATH = 'lorem/root';
const TEST_BRANCH_ID = 'master';
const TEST_BRANCH_ID = 'main';
const TEST_SESSION = {
id: 7,
status: PENDING,
......
......@@ -10,9 +10,9 @@ describe('Multi-file store branch mutations', () => {
describe('SET_CURRENT_BRANCH', () => {
it('sets currentBranch', () => {
mutations.SET_CURRENT_BRANCH(localState, 'master');
mutations.SET_CURRENT_BRANCH(localState, 'main');
expect(localState.currentBranchId).toBe('master');
expect(localState.currentBranchId).toBe('main');
});
});
......@@ -21,20 +21,20 @@ describe('Multi-file store branch mutations', () => {
localState.projects = {
Example: {
branches: {
master: {},
main: {},
},
},
};
mutations.SET_BRANCH_COMMIT(localState, {
projectId: 'Example',
branchId: 'master',
branchId: 'main',
commit: {
title: 'Example commit',
},
});
expect(localState.projects.Example.branches.master.commit.title).toBe('Example commit');
expect(localState.projects.Example.branches.main.commit.title).toBe('Example commit');
});
});
......
......@@ -319,8 +319,8 @@ describe('IDE store file mutations', () => {
localFile.content = 'test';
localFile.changed = true;
localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master';
localState.trees['gitlab-ce/master'] = {
localState.currentBranchId = 'main';
localState.trees['gitlab-ce/main'] = {
tree: [],
};
});
......@@ -337,7 +337,7 @@ describe('IDE store file mutations', () => {
mutations.DISCARD_FILE_CHANGES(localState, localFile.path);
expect(localState.trees['gitlab-ce/master'].tree).toEqual([{ ...localFile, deleted: false }]);
expect(localState.trees['gitlab-ce/main'].tree).toEqual([{ ...localFile, deleted: false }]);
});
it('adds to parent tree if deleted', () => {
......
......@@ -33,16 +33,16 @@ describe('Multi-file store tree mutations', () => {
});
it('adds directory data', () => {
localState.trees['project/master'] = {
localState.trees['project/main'] = {
tree: [],
};
mutations.SET_DIRECTORY_DATA(localState, {
data,
treePath: 'project/master',
treePath: 'project/main',
});
const tree = localState.trees['project/master'];
const tree = localState.trees['project/main'];
expect(tree.tree.length).toBe(3);
expect(tree.tree[0].name).toBe('tree');
......@@ -52,30 +52,30 @@ describe('Multi-file store tree mutations', () => {
it('keeps loading state', () => {
mutations.CREATE_TREE(localState, {
treePath: 'project/master',
treePath: 'project/main',
});
mutations.SET_DIRECTORY_DATA(localState, {
data,
treePath: 'project/master',
treePath: 'project/main',
});
expect(localState.trees['project/master'].loading).toBe(true);
expect(localState.trees['project/main'].loading).toBe(true);
});
it('does not override tree already in state, but merges the two with correct order', () => {
const openedFile = file('new');
localState.trees['project/master'] = {
localState.trees['project/main'] = {
loading: true,
tree: [openedFile],
};
mutations.SET_DIRECTORY_DATA(localState, {
data,
treePath: 'project/master',
treePath: 'project/main',
});
const { tree } = localState.trees['project/master'];
const { tree } = localState.trees['project/main'];
expect(tree.length).toBe(4);
expect(tree[0].name).toBe('blob');
......@@ -86,17 +86,17 @@ describe('Multi-file store tree mutations', () => {
it('returns tree unchanged if the opened file is already in the tree', () => {
const openedFile = file('foo');
localState.trees['project/master'] = {
localState.trees['project/main'] = {
loading: true,
tree: [openedFile],
};
mutations.SET_DIRECTORY_DATA(localState, {
data,
treePath: 'project/master',
treePath: 'project/main',
});
const { tree } = localState.trees['project/master'];
const { tree } = localState.trees['project/main'];
expect(tree.length).toBe(3);
......
......@@ -98,8 +98,8 @@ describe('Multi-file store mutations', () => {
describe('CREATE_TMP_ENTRY', () => {
beforeEach(() => {
localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master';
localState.trees['gitlab-ce/master'] = {
localState.currentBranchId = 'main';
localState.trees['gitlab-ce/main'] = {
tree: [],
};
});
......@@ -115,7 +115,7 @@ describe('Multi-file store mutations', () => {
},
});
expect(localState.trees['gitlab-ce/master'].tree.length).toEqual(1);
expect(localState.trees['gitlab-ce/main'].tree.length).toEqual(1);
expect(localState.entries.test.tempFile).toEqual(true);
});
});
......@@ -163,8 +163,8 @@ describe('Multi-file store mutations', () => {
describe('DELETE_ENTRY', () => {
beforeEach(() => {
localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master';
localState.trees['gitlab-ce/master'] = {
localState.currentBranchId = 'main';
localState.trees['gitlab-ce/main'] = {
tree: [],
};
});
......@@ -184,11 +184,11 @@ describe('Multi-file store mutations', () => {
path: 'filePath',
deleted: false,
};
localState.trees['gitlab-ce/master'].tree.push(localState.entries.filePath);
localState.trees['gitlab-ce/main'].tree.push(localState.entries.filePath);
mutations.DELETE_ENTRY(localState, 'filePath');
expect(localState.trees['gitlab-ce/master'].tree).toEqual([]);
expect(localState.trees['gitlab-ce/main'].tree).toEqual([]);
});
it('removes from parent tree', () => {
......@@ -279,12 +279,12 @@ describe('Multi-file store mutations', () => {
describe('RENAME_ENTRY', () => {
beforeEach(() => {
localState.trees = {
'gitlab-ce/master': {
'gitlab-ce/main': {
tree: [],
},
};
localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master';
localState.currentBranchId = 'main';
localState.entries = {
oldPath: file('oldPath', 'oldPath', 'blob'),
};
......@@ -462,7 +462,7 @@ describe('Multi-file store mutations', () => {
gamma,
};
localState.trees['gitlab-ce/master'].tree = [alpha, beta, gamma];
localState.trees['gitlab-ce/main'].tree = [alpha, beta, gamma];
mutations.RENAME_ENTRY(localState, {
path: 'alpha',
......@@ -471,7 +471,7 @@ describe('Multi-file store mutations', () => {
parentPath: '',
});
expect(localState.trees['gitlab-ce/master'].tree).toEqual([
expect(localState.trees['gitlab-ce/main'].tree).toEqual([
expect.objectContaining({
name: 'beta',
}),
......
......@@ -18,13 +18,13 @@ describe('Multi-file store utils', () => {
};
const state = {
currentBranchId: 'master',
currentBranchId: 'main',
currentProjectId: 'test/test',
};
utils.setPageTitleForFile(state, f);
expect(document.title).toBe('README.md · master · test/test · GitLab');
expect(document.title).toBe('README.md · main · test/test · GitLab');
});
});
......@@ -52,10 +52,10 @@ describe('Multi-file store utils', () => {
{ ...file('deletedFile'), path: 'deletedFile', deleted: true },
{ ...file('renamedFile'), path: 'renamedFile', prevPath: 'prevPath' },
],
currentBranchId: 'master',
currentBranchId: 'main',
};
const payload = utils.createCommitPayload({
branch: 'master',
branch: 'main',
newBranch: false,
state,
rootState,
......@@ -63,7 +63,7 @@ describe('Multi-file store utils', () => {
});
expect(payload).toEqual({
branch: 'master',
branch: 'main',
commit_message: 'commit message',
actions: [
{
......@@ -122,10 +122,10 @@ describe('Multi-file store utils', () => {
lastCommitSha: '123456789',
},
],
currentBranchId: 'master',
currentBranchId: 'main',
};
const payload = utils.createCommitPayload({
branch: 'master',
branch: 'main',
newBranch: false,
state: {},
rootState,
......@@ -135,7 +135,7 @@ describe('Multi-file store utils', () => {
});
expect(payload).toEqual({
branch: 'master',
branch: 'main',
commit_message: 'prebuilt test commit message',
actions: [
{
......@@ -377,7 +377,7 @@ describe('Multi-file store utils', () => {
let localState;
let branchInfo;
const currentProjectId = '123-foo';
const currentBranchId = 'master';
const currentBranchId = 'main';
beforeEach(() => {
localState = {
......
......@@ -274,33 +274,33 @@ describe('WebIDE utils', () => {
* hello.md -> hello-1.md
* hello_2.md -> hello_3.md
* hello_ -> hello_1
* master-patch-22432 -> master-patch-22433
* main-patch-22432 -> main-patch-22433
* patch_332 -> patch_333
*/
describe('addNumericSuffix', () => {
it.each`
input | output
${'hello'} | ${'hello-1'}
${'hello2'} | ${'hello-3'}
${'hello.md'} | ${'hello-1.md'}
${'hello_2.md'} | ${'hello_3.md'}
${'hello_'} | ${'hello_1'}
${'master-patch-22432'} | ${'master-patch-22433'}
${'patch_332'} | ${'patch_333'}
input | output
${'hello'} | ${'hello-1'}
${'hello2'} | ${'hello-3'}
${'hello.md'} | ${'hello-1.md'}
${'hello_2.md'} | ${'hello_3.md'}
${'hello_'} | ${'hello_1'}
${'main-patch-22432'} | ${'main-patch-22433'}
${'patch_332'} | ${'patch_333'}
`('adds a numeric suffix to a given filename/branch name: $input', ({ input, output }) => {
expect(addNumericSuffix(input)).toBe(output);
});
it.each`
input | output
${'hello'} | ${'hello-39135'}
${'hello2'} | ${'hello-39135'}
${'hello.md'} | ${'hello-39135.md'}
${'hello_2.md'} | ${'hello_39135.md'}
${'hello_'} | ${'hello_39135'}
${'master-patch-22432'} | ${'master-patch-39135'}
${'patch_332'} | ${'patch_39135'}
input | output
${'hello'} | ${'hello-39135'}
${'hello2'} | ${'hello-39135'}
${'hello.md'} | ${'hello-39135.md'}
${'hello_2.md'} | ${'hello_39135.md'}
${'hello_'} | ${'hello_39135'}
${'main-patch-22432'} | ${'main-patch-39135'}
${'patch_332'} | ${'patch_39135'}
`('adds a random suffix if randomize=true is passed for name: $input', ({ input, output }) => {
jest.spyOn(Math, 'random').mockReturnValue(0.391352525);
......
......@@ -3,8 +3,8 @@ import ActionsButton from '~/vue_shared/components/actions_button.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import WebIdeLink from '~/vue_shared/components/web_ide_link.vue';
const TEST_EDIT_URL = '/gitlab-test/test/-/edit/master/';
const TEST_WEB_IDE_URL = '/-/ide/project/gitlab-test/test/edit/master/-/';
const TEST_EDIT_URL = '/gitlab-test/test/-/edit/main/';
const TEST_WEB_IDE_URL = '/-/ide/project/gitlab-test/test/edit/main/-/';
const TEST_GITPOD_URL = 'https://gitpod.test/';
const ACTION_EDIT = {
......
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