Skip to content

Commit cd41230

Browse files
authored
Fix external group metadata changes are not merged (#8994)
1 parent 76f0063 commit cd41230

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
5959
- We fixed a bug where switching between themes will cause an error/exception. [#8939](https://github.com/JabRef/jabref/pull/8939)
6060
- We fixed a bug where files that were deleted in the source bibtex file were kept in the index. [#8962](https://github.com/JabRef/jabref/pull/8962)
6161
- We fixed "Error while sending to JabRef" when the browser extension interacts with JabRef. [JabRef-Browser-Extension#479](https://github.com/JabRef/JabRef-Browser-Extension/issues/479)
62+
- We fixed a bug that prevented external group metadata changes from being merged. [#8873](https://github.com/JabRef/jabref/issues/8873)
6263

6364
### Removed
6465

Diff for: src/main/java/org/jabref/gui/collab/MetaDataChangeViewModel.java

+3
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ public Node description() {
3939
@Override
4040
public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {
4141
database.setMetaData(metaDataDiff.getNewMetaData());
42+
// group change is handled by GroupChangeViewModel, so we set the groups root to the original value
43+
// to prevent any inconsistency
44+
metaDataDiff.getGroupDifferences().ifPresent(groupDiff -> database.getMetaData().setGroups(groupDiff.getOriginalGroupRoot()));
4245
}
4346
}

Diff for: src/main/java/org/jabref/logic/bibtex/comparator/GroupDiff.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static Optional<GroupDiff> compare(MetaData originalMetaData, MetaData ne
2323
final Optional<GroupTreeNode> newGroups = newMetaData.getGroups();
2424

2525
if (!originalGroups.equals(newGroups)) {
26-
return Optional.of(new GroupDiff(newGroups.orElse(null), originalGroups.orElse(null)));
26+
return Optional.of(new GroupDiff(originalGroups.orElse(null), newGroups.orElse(null)));
2727
} else {
2828
return Optional.empty();
2929
}

Diff for: src/test/java/org/jabref/logic/bibtex/comparator/GroupDiffTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void compareWithChangedGroup() {
5656

5757
Optional<GroupDiff> groupDiff = GroupDiff.compare(originalMetaData, newMetaData);
5858

59-
Optional<GroupDiff> expectedGroupDiff = Optional.of(new GroupDiff(newMetaData.getGroups().get(), originalMetaData.getGroups().get()));
59+
Optional<GroupDiff> expectedGroupDiff = Optional.of(new GroupDiff(originalMetaData.getGroups().get(), newMetaData.getGroups().get()));
6060

6161
assertEquals(expectedGroupDiff.get().getNewGroupRoot(), groupDiff.get().getNewGroupRoot());
6262
assertEquals(expectedGroupDiff.get().getOriginalGroupRoot(), groupDiff.get().getOriginalGroupRoot());

0 commit comments

Comments
 (0)