diff options
author | Paul Slaughter <pslaughter@gitlab.com> | 2019-06-17 20:53:58 +0300 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2019-06-17 22:04:35 +0300 |
commit | 894ad6f6e983cb17c7b63b4185c63a42b6203a4f (patch) | |
tree | bd3990e5b4fe0e9521287bf0c327925a82084c50 /app/assets/javascripts/ide/stores | |
parent | 89a89b3230717920410de6fb6d6b7152ef41a03e (diff) |
Fix IDE commit to use start_ref
**Why?**
The branch HEAD could be changed since the
IDE was opened. This leads to user's unintentionally
creating commits that overwrite other changes.
https://gitlab.com/gitlab-org/gitlab-ce/issues/59023
Diffstat (limited to 'app/assets/javascripts/ide/stores')
-rw-r--r-- | app/assets/javascripts/ide/stores/modules/commit/actions.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/utils.js | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/commit/actions.js b/app/assets/javascripts/ide/stores/modules/commit/actions.js index 51062f092ad..ff1255ce749 100644 --- a/app/assets/javascripts/ide/stores/modules/commit/actions.js +++ b/app/assets/javascripts/ide/stores/modules/commit/actions.js @@ -142,6 +142,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo getters, state, rootState, + rootGetters, }); return service.commit(rootState.currentProjectId, payload); diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js index bcc9ca60d9b..4e7a8765abe 100644 --- a/app/assets/javascripts/ide/stores/utils.js +++ b/app/assets/javascripts/ide/stores/utils.js @@ -135,7 +135,14 @@ export const getCommitFiles = stagedFiles => }); }, []); -export const createCommitPayload = ({ branch, getters, newBranch, state, rootState }) => ({ +export const createCommitPayload = ({ + branch, + getters, + newBranch, + state, + rootState, + rootGetters, +}) => ({ branch, commit_message: state.commitMessage || getters.preBuiltCommitMessage, actions: getCommitFiles(rootState.stagedFiles).map(f => ({ @@ -146,7 +153,7 @@ export const createCommitPayload = ({ branch, getters, newBranch, state, rootSta encoding: f.base64 ? 'base64' : 'text', last_commit_id: newBranch || f.deleted || f.prevPath ? undefined : f.lastCommitSha, })), - start_branch: newBranch ? rootState.currentBranchId : undefined, + start_sha: newBranch ? rootGetters.lastCommit.short_id : undefined, }); export const createNewMergeRequestUrl = (projectUrl, source, target) => |