Skip to content

Commit

Permalink
Merge branch 'main' into build-journal-lists-on-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Sep 2, 2023
2 parents d78ce5a + 57f97f2 commit c80630e
Show file tree
Hide file tree
Showing 59 changed files with 532 additions and 260 deletions.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ body:
attributes:
label: JabRef version
options:
- "5.9 (latest release)"
- "3.8.2"
- "5.10 (latest release)"
- Latest development branch build (please note build date below)
- Other (please describe below)
description: The version as shown in the about dialog.
Expand Down Expand Up @@ -42,7 +41,7 @@ body:

- type: checkboxes
attributes:
label: Checked with the latest development build
label: Checked with the latest development build (copy version output from About dialog)
description: |
Please always test if the bug is still reproducible in the latest development version. We are constantly improving JabRef and some bugs may already be fixed. If you already use a development version, ensure that you use the latest one.
You can download the latest development build at: https://builds.jabref.org/main/ . **Please make a backup of your library before you try out this version.**
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deployment-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
xcrun notarytool submit build/distribution/JabRef-${{ steps.gitversion.outputs.Major }}.${{ steps.gitversion.outputs.Minor }}-arm64.pkg --keychain-profile "notarytool-profile" --keychain ${{runner.temp}}/keychain/notarization.keychain --wait
xcrun stapler staple build/distribution/JabRef-${{ steps.gitversion.outputs.Major }}.${{ steps.gitversion.outputs.Minor }}-arm64.pkg
- name: Upload with rsync
if: ! startsWith(github.ref, 'refs/heads/gh-readonly-queue')
if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
shell: bash
run: |
mkdir ${{runner.temp}}/sshkey
Expand All @@ -173,7 +173,7 @@ jobs:
fi
rsync -Pavz --itemize-changes --stats --partial-dir=/tmp/partial --rsync-path="mkdir -p /var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }} && rsync" -e 'ssh -p 9922 -i ~/.ssh/id_rsa' build/distribution/ [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/
- name: Upload to GitHub workflow artifacts store
if: ! startsWith(github.ref, 'refs/heads/gh-readonly-queue')
if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
uses: actions/upload-artifact@v3
with:
name: JabRef-${{ matrix.displayName }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
rm debian-binary control.tar.* data.tar.*
mv -f jabref_${{ steps.gitversion.outputs.Major }}.${{ steps.gitversion.outputs.Minor }}_amd64_repackaged.deb jabref_${{ steps.gitversion.outputs.Major }}.${{ steps.gitversion.outputs.Minor }}_amd64.deb
- name: Upload to builds.jabref.org (ubuntu)
if: (matrix.os == 'ubuntu-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (! startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
if: (matrix.os == 'ubuntu-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (!startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
uses: Pendect/[email protected]
env:
DEPLOY_KEY: ${{ secrets.buildJabRefPrivateKey }}
Expand All @@ -240,13 +240,13 @@ jobs:
src: 'build/distribution/'
dest: [email protected]:/var/www/builds.jabref.org/www/${{ steps.gitversion.outputs.branchName }}/
- name: Upload to GitHub workflow artifacts store (windows)
if: (matrix.os == 'windows-latest') && (! startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
if: (matrix.os == 'windows-latest') && (!startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
uses: actions/upload-artifact@v3
with:
name: JabRef-${{ matrix.displayName }}
path: build/distribution
- name: Upload to GitHub workflow artifacts store (macos)
if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (! startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (!startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
uses: actions/upload-artifact@v3
with:
# tbn = to-be-notarized
Expand Down Expand Up @@ -307,7 +307,7 @@ jobs:
shell: bash
run: ${{ matrix.archivePortable }}
- name: Upload to GitHub workflow artifacts store
if: (steps.checksecrets.outputs.secretspresent == 'YES') && (! startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
if: (steps.checksecrets.outputs.secretspresent == 'YES') && (!startsWith(github.ref, 'refs/heads/gh-readonly-queue'))
uses: actions/upload-artifact@v3
with:
name: JabRef-macOS
Expand All @@ -318,7 +318,7 @@ jobs:
name: Upload binaries on builds.jabref.org
runs-on: ubuntu-latest
needs: [build, notarize]
if: ! startsWith(github.ref, 'refs/heads/gh-readonly-queue')
if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
steps:
- name: Check secrets presence
id: checksecrets
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
name: JabRef-windows
path: build/distribution
- name: Get macOS binaries unsigned
if: (steps.checksecrets.outputs.secretspresent == 'YES') && (inputs.notarization == false && ! startsWith(github.ref, 'refs/tags/'))
if: (steps.checksecrets.outputs.secretspresent == 'YES') && (inputs.notarization == false && !startsWith(github.ref, 'refs/tags/'))
uses: actions/download-artifact@master
with:
name: JabRef-macOS-tbn
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -478,5 +478,7 @@ lib/ojdbc.jar
# do not ignore JabRef icons (they are ignored by the macos setting above)
!src/main/java/org/jabref/gui/icon

!**/autosaveandbackup/*.bak

# generated during release process
CHANGELOG.html
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- It is possible again to use "current table sort order" for the order of entries when saving. [#9869](https://github.com/JabRef/jabref/issues/9869)

### Removed

## [5.10] - 2023-09-02
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.autosaveandbackup.AutosaveManager;
import org.jabref.gui.autosaveandbackup.BackupManager;
import org.jabref.gui.auximport.NewSubLibraryAction;
import org.jabref.gui.bibtexextractor.ExtractBibtexAction;
import org.jabref.gui.citationkeypattern.GenerateCitationKeyAction;
Expand Down Expand Up @@ -118,8 +120,6 @@
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.autosaveandbackup.AutosaveManager;
import org.jabref.logic.autosaveandbackup.BackupManager;
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.importer.IdFetcher;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.jabref.gui.autocompleter.AutoCompletePreferences;
import org.jabref.gui.autocompleter.PersonNameSuggestionProvider;
import org.jabref.gui.autocompleter.SuggestionProviders;
import org.jabref.gui.autosaveandbackup.AutosaveManager;
import org.jabref.gui.autosaveandbackup.BackupManager;
import org.jabref.gui.collab.DatabaseChangeMonitor;
import org.jabref.gui.dialogs.AutosaveUiManager;
import org.jabref.gui.entryeditor.EntryEditor;
Expand All @@ -39,8 +41,6 @@
import org.jabref.gui.undo.UndoableRemoveEntries;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.logic.autosaveandbackup.AutosaveManager;
import org.jabref.logic.autosaveandbackup.BackupManager;
import org.jabref.logic.citationstyle.CitationStyleCache;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.util.FileFieldParser;
Expand Down Expand Up @@ -294,7 +294,7 @@ public void installAutosaveManagerAndBackupManager() {
autosaveManager.registerListener(new AutosaveUiManager(this, preferencesService, entryTypesManager));
}
if (isDatabaseReadyForBackup(bibDatabaseContext) && preferencesService.getFilePreferences().shouldCreateBackup()) {
BackupManager.start(bibDatabaseContext, Globals.entryTypesManager, preferencesService);
BackupManager.start(this, bibDatabaseContext, Globals.entryTypesManager, preferencesService);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.logic.autosaveandbackup;
package org.jabref.gui.autosaveandbackup;

import java.util.HashSet;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jabref.logic.autosaveandbackup;
package org.jabref.gui.autosaveandbackup;

import java.io.IOException;
import java.io.Writer;
Expand All @@ -19,6 +19,11 @@
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javafx.scene.control.TableColumn;

import org.jabref.gui.LibraryTab;
import org.jabref.gui.maintable.BibEntryTableViewModel;
import org.jabref.gui.maintable.columns.MainTableColumn;
import org.jabref.logic.bibtex.InvalidFieldValueException;
import org.jabref.logic.exporter.AtomicFileWriter;
import org.jabref.logic.exporter.BibWriter;
Expand All @@ -31,6 +36,7 @@
import org.jabref.model.database.event.BibDatabaseContextChangedEvent;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.metadata.SaveOrder;
import org.jabref.model.metadata.SelfContainedSaveOrder;
import org.jabref.preferences.PreferencesService;

import com.google.common.eventbus.Subscribe;
Expand Down Expand Up @@ -58,17 +64,19 @@ public class BackupManager {
private final ScheduledThreadPoolExecutor executor;
private final CoarseChangeFilter changeFilter;
private final BibEntryTypesManager entryTypesManager;
private final LibraryTab libraryTab;

// Contains a list of all backup paths
// During a write, the less recent backup file is deleted
private final Queue<Path> backupFilesQueue = new LinkedBlockingQueue<>();
private boolean needsBackup = false;

BackupManager(BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService preferences) {
BackupManager(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService preferences) {
this.bibDatabaseContext = bibDatabaseContext;
this.entryTypesManager = entryTypesManager;
this.preferences = preferences;
this.executor = new ScheduledThreadPoolExecutor(2);
this.libraryTab = libraryTab;

changeFilter = new CoarseChangeFilter(bibDatabaseContext);
changeFilter.registerListener(this);
Expand Down Expand Up @@ -96,8 +104,8 @@ static Optional<Path> getLatestBackupPath(Path originalPath, Path backupDir) {
*
* @param bibDatabaseContext Associated {@link BibDatabaseContext}
*/
public static BackupManager start(BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService preferences) {
BackupManager backupManager = new BackupManager(bibDatabaseContext, entryTypesManager, preferences);
public static BackupManager start(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService preferences) {
BackupManager backupManager = new BackupManager(libraryTab, bibDatabaseContext, entryTypesManager, preferences);
backupManager.startBackupTask(preferences.getFilePreferences().getBackupDirectory());
runningInstances.add(backupManager);
return backupManager;
Expand Down Expand Up @@ -215,18 +223,36 @@ void performBackup(Path backupPath) {

// We opted for "while" to delete backups in case there are more than 10
while (backupFilesQueue.size() >= MAXIMUM_BACKUP_FILE_COUNT) {
Path lessRecentBackupFile = backupFilesQueue.poll();
Path oldestBackupFile = backupFilesQueue.poll();
try {
Files.delete(lessRecentBackupFile);
Files.delete(oldestBackupFile);
} catch (IOException e) {
LOGGER.error("Could not delete backup file {}", lessRecentBackupFile, e);
LOGGER.error("Could not delete backup file {}", oldestBackupFile, e);
}
}

// code similar to org.jabref.gui.exporter.SaveDatabaseAction.saveDatabase
SelfContainedSaveOrder saveOrder = bibDatabaseContext
.getMetaData().getSaveOrder()
.map(so -> {
if (so.getOrderType() == SaveOrder.OrderType.TABLE) {
// We need to "flatten out" SaveOrder.OrderType.TABLE as BibWriter does not have access to preferences
List<TableColumn<BibEntryTableViewModel, ?>> sortOrder = libraryTab.getMainTable().getSortOrder();
return new SelfContainedSaveOrder(
SaveOrder.OrderType.SPECIFIED,
sortOrder.stream()
.filter(col -> col instanceof MainTableColumn<?>)
.map(column -> ((MainTableColumn<?>) column).getModel())
.flatMap(model -> model.getSortCriteria().stream())
.toList());
} else {
return SelfContainedSaveOrder.of(so);
}
})
.orElse(SaveOrder.getDefaultSaveOrder());
SaveConfiguration saveConfiguration = new SaveConfiguration()
.withMakeBackup(false)
.withSaveOrder(bibDatabaseContext.getMetaData().getSaveOrder().orElse(SaveOrder.getDefaultSaveOrder()))
.withSaveOrder(saveOrder)
.withReformatOnSave(preferences.getLibraryPreferences().shouldAlwaysReformatOnSave());

Charset encoding = bibDatabaseContext.getMetaData().getEncoding().orElse(StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.collab.metedatachange;

import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;

import org.jabref.gui.collab.DatabaseChangeDetailsView;
Expand All @@ -17,20 +18,24 @@ public MetadataChangeDetailsView(MetadataChange metadataChange, PreferencesServi
header.getStyleClass().add("sectionHeader");
container.getChildren().add(header);

for (MetaDataDiff.Difference change : metadataChange.getMetaDataDiff().getDifferences(preferencesService)) {
container.getChildren().add(new Label(getDifferenceString(change)));
for (MetaDataDiff.Difference diff : metadataChange.getMetaDataDiff().getDifferences(preferencesService)) {
container.getChildren().add(new Label(getDifferenceString(diff.differenceType())));
container.getChildren().add(new Label(diff.originalObject().toString()));
container.getChildren().add(new Label(diff.newObject().toString()));
}

setLeftAnchor(container, 8d);
setTopAnchor(container, 8d);
setRightAnchor(container, 8d);
setBottomAnchor(container, 8d);
ScrollPane scrollPane = new ScrollPane(container);
scrollPane.setFitToWidth(true);
getChildren().setAll(scrollPane);

getChildren().setAll(container);
setLeftAnchor(scrollPane, 8d);
setTopAnchor(scrollPane, 8d);
setRightAnchor(scrollPane, 8d);
setBottomAnchor(scrollPane, 8d);
}

private String getDifferenceString(MetaDataDiff.Difference change) {
return switch (change) {
private String getDifferenceString(MetaDataDiff.DifferenceType changeType) {
return switch (changeType) {
case PROTECTED ->
Localization.lang("Library protection");
case GROUPS_ALTERED ->
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/dialogs/BackupUIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import javafx.scene.control.ButtonType;

import org.jabref.gui.DialogService;
import org.jabref.gui.autosaveandbackup.BackupManager;
import org.jabref.gui.backup.BackupResolverDialog;
import org.jabref.gui.collab.DatabaseChange;
import org.jabref.gui.collab.DatabaseChangeList;
import org.jabref.gui.collab.DatabaseChangeResolverFactory;
import org.jabref.gui.collab.DatabaseChangesResolverDialog;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.logic.autosaveandbackup.BackupManager;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.logic.importer.OpenDatabase;
import org.jabref.logic.importer.ParserResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected Set<Field> determineFieldsToShow(BibEntry entry) {
Set<Field> fields = new LinkedHashSet<>();
if (entryType.isPresent()) {
for (OrFields orFields : entryType.get().getRequiredFields()) {
fields.addAll(orFields);
fields.addAll(orFields.getFields());
}
// Add the edit field for Bibtex-key.
fields.add(InternalField.KEY_FIELD);
Expand Down
Loading

0 comments on commit c80630e

Please sign in to comment.