parent
7ff0dbc54f
commit
177a5e69b6
3 changed files with 38 additions and 1 deletions
|
@ -200,6 +200,7 @@ export default {
|
|||
},
|
||||
[types.DELETE_ENTRY](state, path) {
|
||||
const entry = state.entries[path];
|
||||
const { tempFile = false } = entry;
|
||||
const parent = entry.parentPath
|
||||
? state.entries[entry.parentPath]
|
||||
: state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
|
||||
|
@ -209,7 +210,11 @@ export default {
|
|||
parent.tree = parent.tree.filter(f => f.path !== entry.path);
|
||||
|
||||
if (entry.type === 'blob') {
|
||||
state.changedFiles = state.changedFiles.concat(entry);
|
||||
if (tempFile) {
|
||||
state.changedFiles = state.changedFiles.filter(f => f.path !== path);
|
||||
} else {
|
||||
state.changedFiles = state.changedFiles.concat(entry);
|
||||
}
|
||||
}
|
||||
},
|
||||
[types.RENAME_ENTRY](state, { path, name, entryPath = null }) {
|
||||
|
|
5
changelogs/unreleased/ide-delete-new-files-state.yml
Normal file
5
changelogs/unreleased/ide-delete-new-files-state.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fixed IDE deleting new files creating wrong state
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -213,6 +213,33 @@ describe('Multi-file store mutations', () => {
|
|||
|
||||
expect(localState.changedFiles).toEqual([localState.entries.filePath]);
|
||||
});
|
||||
|
||||
it('does not add tempFile into changedFiles', () => {
|
||||
localState.entries.filePath = {
|
||||
deleted: false,
|
||||
type: 'blob',
|
||||
tempFile: true,
|
||||
};
|
||||
|
||||
mutations.DELETE_ENTRY(localState, 'filePath');
|
||||
|
||||
expect(localState.changedFiles).toEqual([]);
|
||||
});
|
||||
|
||||
it('removes tempFile from changedFiles when deleted', () => {
|
||||
localState.entries.filePath = {
|
||||
path: 'filePath',
|
||||
deleted: false,
|
||||
type: 'blob',
|
||||
tempFile: true,
|
||||
};
|
||||
|
||||
localState.changedFiles.push({ ...localState.entries.filePath });
|
||||
|
||||
mutations.DELETE_ENTRY(localState, 'filePath');
|
||||
|
||||
expect(localState.changedFiles).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('UPDATE_FILE_AFTER_COMMIT', () => {
|
||||
|
|
Loading…
Reference in a new issue