Commit 96564b36 authored by Paul Slaughter's avatar Paul Slaughter

Fix IDE commit to new branch routing

This actually caused a number of issues and
left the Web IDE in a broken state.
parent 0d75b670
...@@ -44,8 +44,9 @@ export const refreshLastCommitData = ({ commit }, { projectId, branchId } = {}) ...@@ -44,8 +44,9 @@ export const refreshLastCommitData = ({ commit }, { projectId, branchId } = {})
commit: data.commit, commit: data.commit,
}); });
}) })
.catch(() => { .catch((e) => {
flash(__('Error loading last commit.'), 'alert', document, null, false, true); flash(__('Error loading last commit.'), 'alert', document, null, false, true);
throw e;
}); });
export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch) => export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch) =>
......
...@@ -204,26 +204,25 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo ...@@ -204,26 +204,25 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
} else { } else {
dispatch('updateActivityBarView', leftSidebarViews.edit.name, { root: true }); dispatch('updateActivityBarView', leftSidebarViews.edit.name, { root: true });
dispatch('updateViewer', 'editor', { root: true }); dispatch('updateViewer', 'editor', { root: true });
if (rootGetters.activeFile) {
dispatch(
'router/push',
`/project/${rootState.currentProjectId}/blob/${branchName}/-/${rootGetters.activeFile.path}`,
{ root: true },
);
}
} }
}) })
.then(() => dispatch('updateCommitAction', consts.COMMIT_TO_CURRENT_BRANCH)) .then(() => dispatch('updateCommitAction', consts.COMMIT_TO_CURRENT_BRANCH))
.then(() => .then(() => {
dispatch( if (newBranch) {
const path = rootGetters.activeFile ? rootGetters.activeFile.path : '';
return dispatch(
'router/push',
`/project/${rootState.currentProjectId}/blob/${branchName}/-/${path}`,
{ root: true },
);
}
return dispatch(
'refreshLastCommitData', 'refreshLastCommitData',
{ { projectId: rootState.currentProjectId, branchId: branchName },
projectId: rootState.currentProjectId,
branchId: rootState.currentBranchId,
},
{ root: true }, { root: true },
), );
); });
}); });
}; };
---
title: Fix issues when Web IDE commits to new branch
merge_request: 51654
author:
type: fixed
...@@ -19,6 +19,17 @@ jest.mock('~/lib/utils/url_utility', () => ({ ...@@ -19,6 +19,17 @@ jest.mock('~/lib/utils/url_utility', () => ({
})); }));
const TEST_COMMIT_SHA = '123456789'; const TEST_COMMIT_SHA = '123456789';
const COMMIT_RESPONSE = {
id: '123456',
short_id: '123',
message: 'test message',
committed_date: 'date',
parent_ids: [],
stats: {
additions: '1',
deletions: '2',
},
};
describe('IDE commit module actions', () => { describe('IDE commit module actions', () => {
let mock; let mock;
...@@ -32,7 +43,9 @@ describe('IDE commit module actions', () => { ...@@ -32,7 +43,9 @@ describe('IDE commit module actions', () => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
jest.spyOn(router, 'push').mockImplementation(); jest.spyOn(router, 'push').mockImplementation();
mock.onGet('/api/v1/projects/abcproject/repository/branches/master').reply(200); mock
.onGet('/api/v1/projects/abcproject/repository/branches/master')
.reply(200, { commit: COMMIT_RESPONSE });
}); });
afterEach(() => { afterEach(() => {
...@@ -329,18 +342,6 @@ describe('IDE commit module actions', () => { ...@@ -329,18 +342,6 @@ describe('IDE commit module actions', () => {
}); });
describe('success', () => { describe('success', () => {
const COMMIT_RESPONSE = {
id: '123456',
short_id: '123',
message: 'test message',
committed_date: 'date',
parent_ids: '321',
stats: {
additions: '1',
deletions: '2',
},
};
beforeEach(() => { beforeEach(() => {
jest.spyOn(service, 'commit').mockResolvedValue({ data: COMMIT_RESPONSE }); jest.spyOn(service, 'commit').mockResolvedValue({ data: COMMIT_RESPONSE });
}); });
...@@ -544,18 +545,6 @@ describe('IDE commit module actions', () => { ...@@ -544,18 +545,6 @@ describe('IDE commit module actions', () => {
}); });
describe('first commit of a branch', () => { describe('first commit of a branch', () => {
const COMMIT_RESPONSE = {
id: '123456',
short_id: '123',
message: 'test message',
committed_date: 'date',
parent_ids: [],
stats: {
additions: '1',
deletions: '2',
},
};
it('commits TOGGLE_EMPTY_STATE mutation on empty repo', (done) => { it('commits TOGGLE_EMPTY_STATE mutation on empty repo', (done) => {
jest.spyOn(service, 'commit').mockResolvedValue({ data: COMMIT_RESPONSE }); jest.spyOn(service, 'commit').mockResolvedValue({ data: COMMIT_RESPONSE });
jest.spyOn(store, 'commit'); jest.spyOn(store, 'commit');
......
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