-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add feature to merge .bib files into current bib #13320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d348089
e415652
984133d
4987209
81cd997
e7736a4
d01814c
ac0b688
e15d40d
a358457
e892ec3
16c4365
9b45c43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -105,7 +105,7 @@ public void mergeBibFilesIntoCurrentBib(Path directory, BibDatabaseContext conte | |||||
try { | ||||||
result = OpenDatabase.loadDatabase(path, preferences.getImportFormatPreferences(), fileUpdateMonitor); | ||||||
} catch (IOException e) { | ||||||
LOGGER.error("Could not load file '{}': {}", path, e.getMessage()); | ||||||
LOGGER.error("Could not load file '{}': {}", path, e.getMessage(), e); | ||||||
continue; | ||||||
} | ||||||
for (BibEntry toMergeEntry : result.getDatabase().getEntries()) { | ||||||
|
@@ -167,7 +167,7 @@ private List<Path> getAllBibFiles(Path directory, Path databasePath) { | |||||
)) { | ||||||
return stream.collect(Collectors.toList()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} catch (IOException e) { | ||||||
LOGGER.error("Error finding .bib files in '{}': {}", directory.getFileName(), e.getMessage()); | ||||||
LOGGER.error("Error finding .bib files in '{}': {}", directory.getFileName(), e.getMessage(), e); | ||||||
} | ||||||
return List.of(); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,7 +203,7 @@ public void sameCitationKeyMergeTest() { | |
); | ||
|
||
action.execute(); | ||
assertEquals(1, mockedMergeEntriesAction.constructed().size(), "MergeEntriesAction was not created as expected"); | ||
assertEquals(1, mockedMergeEntriesAction.constructed().size(), "Expected 1 MergeEntriesAction instance but found"); | ||
} | ||
} | ||
|
||
|
@@ -250,14 +250,12 @@ public void sameCitationKeyNoMergePreferenceTest() { | |
@Test | ||
public void duplicateMergeTest() { | ||
BibEntry currentEntry = new BibEntry(StandardEntryType.Article) | ||
.withCitationKey("DIFFERENTCITATIONKEY") | ||
.withCitationKey("DIFFERENT CITATION KEY") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think bibtex or biblatex allow multiple words as citation keys. The documentation does not say anything about this, but there are hints. I was looking into the source of biber but was not able to quickly locate the parser for citation keys (https://github.com/plk/biber/blob/dev/lib/Biber.pm). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its possible with BibLaTeX: https://tex.stackexchange.com/a/37646/9075 However, it is very seldomly used and we have no proper UI support in JabRef for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neither spaces nor commans are allowed in the key references: https://tex.stackexchange.com/a/271520/9075 |
||
.withField(StandardField.AUTHOR, "Foo Bar") | ||
.withField(StandardField.TITLE, "First Article") | ||
.withField(StandardField.JOURNAL, "International Journal of Something") | ||
.withField(StandardField.YEAR, "2023"); | ||
|
||
currentEntry.setCommentsBeforeEntry("%% Very important paper.\n"); | ||
|
||
BibDatabase currentDatabase = new BibDatabase(); | ||
currentDatabase.insertEntry(currentEntry); | ||
BibDatabaseContext currentContext = new BibDatabaseContext(currentDatabase); | ||
|
@@ -277,7 +275,7 @@ public void duplicateMergeTest() { | |
); | ||
|
||
action.execute(); | ||
assertEquals(1, mockedMergeEntriesAction.constructed().size(), "MergeEntriesAction was not created as expected"); | ||
assertEquals(1, mockedMergeEntriesAction.constructed().size(), "Expected 1 MergeEntriesAction instance but found"); | ||
} | ||
} | ||
|
||
|
@@ -286,14 +284,12 @@ public void duplicateNoMergePreferenceTest() { | |
when(mergeBibFilesIntoCurrentBibPreferences.shouldMergeSameKeyEntries()).thenReturn(false); | ||
when(mergeBibFilesIntoCurrentBibPreferences.shouldMergeDuplicateEntries()).thenReturn(false); | ||
BibEntry currentEntry = new BibEntry(StandardEntryType.Article) | ||
.withCitationKey("DIFFERENTCITATIONKEY") | ||
.withCitationKey("DIFFERENT CITATION KEY") | ||
.withField(StandardField.AUTHOR, "Foo Bar") | ||
.withField(StandardField.TITLE, "First Article") | ||
.withField(StandardField.JOURNAL, "International Journal of Something") | ||
.withField(StandardField.YEAR, "2023"); | ||
|
||
currentEntry.setCommentsBeforeEntry("%% Very important paper.\n"); | ||
|
||
BibDatabase currentDatabase = new BibDatabase(); | ||
currentDatabase.insertEntry(currentEntry); | ||
BibDatabaseContext currentContext = new BibDatabaseContext(currentDatabase); | ||
|
@@ -316,7 +312,7 @@ public void duplicateNoMergePreferenceTest() { | |
assertEquals(1, entries.size(), "Should still have one entry"); | ||
|
||
BibEntry entry1 = entries.stream() | ||
.filter(e -> "DIFFERENTCITATIONKEY".equals(e.getCitationKey().orElse(""))) | ||
.filter(e -> "DIFFERENT CITATION KEY".equals(e.getCitationKey().orElse(""))) | ||
.findFirst() | ||
.orElseThrow(() -> new AssertionError("Entry 'test1' not found")); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be a
dialogService.notify(...)
in additon. Look atJabRef_en.properties
for a nice string to re-use.