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 } = {})
commit: data.commit,
});
})
.catch(() => {
.catch((e) => {
flash(__('Error loading last commit.'), 'alert', document, null, false, true);
throw e;
});
export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch) =>
......
......@@ -204,26 +204,25 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
} else {
dispatch('updateActivityBarView', leftSidebarViews.edit.name, { 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(
.then(() => {
if (newBranch) {
const path = rootGetters.activeFile ? rootGetters.activeFile.path : '';
return dispatch(
'router/push',
`/project/${rootState.currentProjectId}/blob/${branchName}/-/${path}`,
{ root: true },
);
}
return dispatch(
'refreshLastCommitData',
{
projectId: rootState.currentProjectId,
branchId: rootState.currentBranchId,
},
{ projectId: rootState.currentProjectId, branchId: branchName },
{ 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', () => ({
}));
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', () => {
let mock;
......@@ -32,7 +43,9 @@ describe('IDE commit module actions', () => {
mock = new MockAdapter(axios);
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(() => {
......@@ -329,18 +342,6 @@ describe('IDE commit module actions', () => {
});
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(() => {
jest.spyOn(service, 'commit').mockResolvedValue({ data: COMMIT_RESPONSE });
});
......@@ -544,18 +545,6 @@ describe('IDE commit module actions', () => {
});
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) => {
jest.spyOn(service, 'commit').mockResolvedValue({ data: COMMIT_RESPONSE });
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