Skip to content
Snippets Groups Projects
Unverified Commit d4cc92db authored by Paul Slaughter's avatar Paul Slaughter Committed by Markus Koller
Browse files

FE remove create branch call in IDE commit

Previously `start_sha` was intercepted on the frontend to create the
correct branch in a separate API call. Now that the commits API supports
the `start_sha` parameter directly this workaround is not needed
anymore.
parent f8cecafb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -56,13 +56,7 @@ export default {
return Api.branchSingle(projectId, currentBranchId);
},
commit(projectId, payload) {
// Currently the `commit` endpoint does not support `start_sha` so we
// have to make the request in the FE. This is not ideal and will be
// resolved soon. https://gitlab.com/gitlab-org/gitlab-ce/issues/59023
const { branch, start_sha: ref } = payload;
const branchPromise = ref ? Api.createBranch(projectId, { ref, branch }) : Promise.resolve();
return branchPromise.then(() => Api.commitMultiple(projectId, payload));
return Api.commitMultiple(projectId, payload);
},
getFiles(projectUrl, branchId) {
const url = `${projectUrl}/files/${branchId}`;
Loading
Loading
Loading
Loading
@@ -155,7 +155,7 @@ export const createCommitPayload = ({
last_commit_id:
newBranch || f.deleted || f.prevPath || f.replaces ? undefined : f.lastCommitSha,
})),
start_sha: newBranch ? rootGetters.lastCommit.short_id : undefined,
start_sha: newBranch ? rootGetters.lastCommit.id : undefined,
});
 
export const createNewMergeRequestUrl = (projectUrl, source, target) =>
Loading
Loading
Loading
Loading
@@ -16,40 +16,16 @@ describe('IDE services', () => {
branch: TEST_BRANCH,
commit_message: 'Hello world',
actions: [],
start_sha: undefined,
start_sha: TEST_COMMIT_SHA,
};
 
Api.createBranch.mockReturnValue(Promise.resolve());
Api.commitMultiple.mockReturnValue(Promise.resolve());
});
 
describe.each`
startSha | shouldCreateBranch
${undefined} | ${false}
${TEST_COMMIT_SHA} | ${true}
`('when start_sha is $startSha', ({ startSha, shouldCreateBranch }) => {
beforeEach(() => {
payload.start_sha = startSha;
it('should commit', () => {
services.commit(TEST_PROJECT_ID, payload);
 
return services.commit(TEST_PROJECT_ID, payload);
});
if (shouldCreateBranch) {
it('should create branch', () => {
expect(Api.createBranch).toHaveBeenCalledWith(TEST_PROJECT_ID, {
ref: TEST_COMMIT_SHA,
branch: TEST_BRANCH,
});
});
} else {
it('should not create branch', () => {
expect(Api.createBranch).not.toHaveBeenCalled();
});
}
it('should commit', () => {
expect(Api.commitMultiple).toHaveBeenCalledWith(TEST_PROJECT_ID, payload);
});
expect(Api.commitMultiple).toHaveBeenCalledWith(TEST_PROJECT_ID, payload);
});
});
});
Loading
Loading
@@ -245,7 +245,7 @@ describe('IDE commit module actions', () => {
master: {
workingReference: '1',
commit: {
short_id: TEST_COMMIT_SHA,
id: TEST_COMMIT_SHA,
},
},
},
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment