summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/mutations.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-08-01 17:16:21 +0100
committerPhil Hughes <me@iamphill.com>2018-08-01 17:16:21 +0100
commit3f4aaea26c65391098e9e424c4550493a1c525cb (patch)
tree104086d742b61c069aa3f0e9bd65fbecdd6375cc /app/assets/javascripts/ide/stores/mutations.js
parent100c68eecd7ba6f950d1f23d339a2f1ec55675d8 (diff)
downloadgitlab-ce-3f4aaea26c65391098e9e424c4550493a1c525cb.tar.gz
correctly show renaming and deleting entries
for folders, it shows all the files in commit mode for files, nothing changes, the behaviour is the same
Diffstat (limited to 'app/assets/javascripts/ide/stores/mutations.js')
-rw-r--r--app/assets/javascripts/ide/stores/mutations.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations.js b/app/assets/javascripts/ide/stores/mutations.js
index 68fb9d86932..c9e3cbf4592 100644
--- a/app/assets/javascripts/ide/stores/mutations.js
+++ b/app/assets/javascripts/ide/stores/mutations.js
@@ -198,12 +198,18 @@ export default {
: state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
entry.deleted = true;
- state.changedFiles = state.changedFiles.concat(entry);
parent.tree = parent.tree.filter(f => f.path !== entry.path);
+
+ if (entry.type === 'blob') {
+ state.changedFiles = state.changedFiles.concat(entry);
+ }
},
[types.RENAME_ENTRY](state, { path, name, entryPath = null }) {
const oldEntry = state.entries[entryPath || path];
- const nameRegex = new RegExp(`^${path}`);
+ const nameRegex =
+ !entryPath && oldEntry.type === 'blob'
+ ? new RegExp(`${oldEntry.name}$`)
+ : new RegExp(`^${path}`);
const newPath = oldEntry.path.replace(nameRegex, name);
const parentPath = oldEntry.parentPath ? oldEntry.parentPath.replace(nameRegex, name) : '';
@@ -220,15 +226,17 @@ export default {
parentPath,
};
oldEntry.moved = true;
+ oldEntry.movedPath = newPath;
const parent = parentPath
? state.entries[parentPath]
: state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
+ const newEntry = state.entries[newPath];
- parent.tree = sortTree(parent.tree.concat(state.entries[newPath]));
+ parent.tree = sortTree(parent.tree.concat(newEntry));
- if (!entryPath) {
- state.changedFiles = state.changedFiles.concat(state.entries[newPath]);
+ if (newEntry.type === 'blob') {
+ state.changedFiles = state.changedFiles.concat(newEntry);
}
},
...projectMutations,