mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
fix wrong order of svn commits and keep old changesets
This commit is contained in:
@@ -129,15 +129,20 @@ export default function reducer(
|
||||
return state;
|
||||
}
|
||||
|
||||
let oldChangesets = { [key]: {} };
|
||||
if (state[key]) {
|
||||
oldChangesets[key] = state[key];
|
||||
let oldByIds = {};
|
||||
if (state[key] && state[key].byId) {
|
||||
oldByIds = state[key].byId;
|
||||
}
|
||||
|
||||
const byIds = extractChangesetsByIds(changesets);
|
||||
|
||||
return {
|
||||
...state,
|
||||
[key]: {
|
||||
byId: byIds,
|
||||
byId: {
|
||||
...oldByIds,
|
||||
...byIds
|
||||
},
|
||||
list: {
|
||||
entries: changesetIds,
|
||||
entry: {
|
||||
@@ -170,10 +175,14 @@ export function getChangesets(
|
||||
branch?: Branch
|
||||
) {
|
||||
const key = createItemId(repository, branch);
|
||||
if (!state.changesets[key]) {
|
||||
|
||||
const changesets = state.changesets[key];
|
||||
if (!changesets) {
|
||||
return null;
|
||||
}
|
||||
return Object.values(state.changesets[key].byId);
|
||||
return changesets.list.entries.map((id: string) => {
|
||||
return changesets.byId[id];
|
||||
});
|
||||
}
|
||||
|
||||
export function isFetchChangesetsPending(
|
||||
|
||||
@@ -224,6 +224,35 @@ describe("changesets", () => {
|
||||
entries: ["changeset1", "changeset2", "changeset3"]
|
||||
});
|
||||
});
|
||||
|
||||
it("should not remove existing changesets", () => {
|
||||
const state = {
|
||||
"foo/bar": {
|
||||
byId: {
|
||||
id2: { id: "id2" },
|
||||
id1: { id: "id1" }
|
||||
},
|
||||
list: {
|
||||
entries: ["id1", "id2"]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const newState = reducer(
|
||||
state,
|
||||
fetchChangesetsSuccess(repository, undefined, responseBody)
|
||||
);
|
||||
|
||||
const fooBar = newState["foo/bar"];
|
||||
|
||||
expect(fooBar.list.entries).toEqual([
|
||||
"changeset1",
|
||||
"changeset2",
|
||||
"changeset3"
|
||||
]);
|
||||
expect(fooBar.byId["id2"]).toEqual({ id: "id2" });
|
||||
expect(fooBar.byId["id1"]).toEqual({ id: "id1" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("changeset selectors", () => {
|
||||
@@ -234,14 +263,17 @@ describe("changesets", () => {
|
||||
changesets: {
|
||||
"foo/bar": {
|
||||
byId: {
|
||||
id1: { id: "id1" },
|
||||
id2: { id: "id2" }
|
||||
id2: { id: "id2" },
|
||||
id1: { id: "id1" }
|
||||
},
|
||||
list: {
|
||||
entries: ["id1", "id2"]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const result = getChangesets(state, repository);
|
||||
expect(result).toContainEqual({ id: "id1" });
|
||||
expect(result).toEqual([{ id: "id1" }, { id: "id2" }]);
|
||||
});
|
||||
|
||||
it("should return true, when fetching changesets is pending", () => {
|
||||
|
||||
Reference in New Issue
Block a user