Skip to content

Commit 511549f

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Fix typo in PR template Fix: No exception if file is not within a git repository (#13839) Fix lsp4j modules (#13835) New Crowdin updates (#13837)
2 parents 5277005 + 74d5bbf commit 511549f

32 files changed

+94
-97
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Closes _____
77

88
### Steps to test
99

10-
<!-- Describe how reviewers can test this fix/feature. Ideally, think of how you would guide a beginner user of Jabef to try out your change. -->
10+
<!-- Describe how reviewers can test this fix/feature. Ideally, think of how you would guide a beginner user of JabRef to try out your change. -->
1111
<!-- You can add screenshots or videos (using Loom - https://www.loom.com or by just adding .mp4 files). -->
1212
<!-- (REPLACE THIS PARAGRAPH) -->
1313

build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -293,52 +293,38 @@ extraJavaModuleInfo {
293293
module("com.github.javaparser:javaparser-symbol-solver-core", "com.github.javaparser.symbolsolver.core")
294294
module("net.sf.jopt-simple:jopt-simple", "jopt.simple")
295295

296-
// "com.github.eclipse:org.eclipse.lsp4j", "lsp4j"
297-
// - The name 'org.eclipse.lsp4j' is different than the name derived from the Jar file name 'lsp4j'; turn off 'failOnModifiedDerivedModuleNames' or explicitly allow override via 'overrideModuleName()'
298-
// - Not a module and no mapping defined: lsp4j-0.24.0.jar
299-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j", "lsp4j") {
300-
overrideModuleName()
296+
module("org.eclipse.lsp4j:org.eclipse.lsp4j", "org.eclipse.lsp4j") {
301297
exportAllPackages()
302298
requireAllDefinedDependencies()
303-
// Note the missing "lsp4j" at the group
304-
mergeJar("com.github.eclipse:lsp4j")
305299
requires("com.google.gson")
306-
307300
}
308-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j.debug", "lsp4j.debug") {
309-
overrideModuleName()
301+
module("org.eclipse.lsp4j:org.eclipse.lsp4j.debug", "org.eclipse.lsp4j.debug") {
310302
exportAllPackages()
311303
}
312-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j.generator", "lsp4j.generator") {
313-
overrideModuleName()
304+
module("org.eclipse.lsp4j:org.eclipse.lsp4j.generator", "org.eclipse.lsp4j.generator") {
314305
exportAllPackages()
315306
}
316-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc", "lsp4j.jsonrpc") {
317-
overrideModuleName()
307+
module("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc", "org.eclipse.lsp4j.jsonrpc") {
318308
exportAllPackages()
319309
requires("com.google.gson")
320310
requires("java.logging")
321311
}
322-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc.debug", "lsp4j.jsonrpc.debug") {
323-
overrideModuleName()
312+
module("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc.debug", "org.eclipse.lsp4j.jsonrpc.debug") {
324313
exportAllPackages()
325314
}
326-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j.websocket", "lsp4j.websocket") {
327-
overrideModuleName()
315+
module("org.eclipse.lsp4j:org.eclipse.lsp4j.websocket", "org.eclipse.lsp4j.websocket") {
328316
exportAllPackages()
329317
requireAllDefinedDependencies()
330318
}
331-
module("com.github.eclipse.lsp4j:org.eclipse.lsp4j.websocket.jakarta", "lsp4j.websocket.jakarta") {
332-
overrideModuleName()
319+
module("org.eclipse.lsp4j:org.eclipse.lsp4j.websocket.jakarta", "org.eclipse.lsp4j.websocket.jakarta") {
333320
exportAllPackages()
334321
requireAllDefinedDependencies()
335322
}
336323
module("jakarta.websocket:jakarta.websocket-api", "jakarta.websocket") {
337324
overrideModuleName()
338325
exportAllPackages()
339326
}
340-
module("javax.websocket:javax.websocket-api", "javax.websocket") {
341-
overrideModuleName()
327+
module("javax.websocket:javax.websocket-api", "javax.websocket.api") {
342328
exportAllPackages()
343329
}
344330
module("org.eclipse.xtend:org.eclipse.xtend", "xtend") {

jabgui/src/main/java/org/jabref/gui/JabRefGUI.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.jabref.logic.UiCommand;
3838
import org.jabref.logic.ai.AiService;
3939
import org.jabref.logic.citation.SearchCitationsRelationsService;
40+
import org.jabref.logic.git.util.GitHandlerRegistry;
4041
import org.jabref.logic.journals.JournalAbbreviationLoader;
4142
import org.jabref.logic.journals.JournalAbbreviationRepository;
4243
import org.jabref.logic.l10n.Localization;
@@ -84,6 +85,7 @@ public class JabRefGUI extends Application {
8485
private static ClipBoardManager clipBoardManager;
8586
private static DialogService dialogService;
8687
private static JabRefFrame mainFrame;
88+
private static GitHandlerRegistry gitHandlerRegistry;
8789

8890
private static RemoteListenerServerManager remoteListenerServerManager;
8991
private static HttpServerManager httpServerManager;
@@ -119,7 +121,8 @@ public void start(Stage stage) {
119121
countingUndoManager,
120122
Injector.instantiateModelOrService(BibEntryTypesManager.class),
121123
clipBoardManager,
122-
taskExecutor);
124+
taskExecutor,
125+
gitHandlerRegistry);
123126

124127
openWindow();
125128

@@ -157,6 +160,9 @@ public void initialize() {
157160
DirectoryMonitor directoryMonitor = new DirectoryMonitor();
158161
Injector.setModelOrService(DirectoryMonitor.class, directoryMonitor);
159162

163+
gitHandlerRegistry = new GitHandlerRegistry();
164+
Injector.setModelOrService(GitHandlerRegistry.class, gitHandlerRegistry);
165+
160166
BibEntryTypesManager entryTypesManager = preferences.getCustomEntryTypesRepository();
161167
JournalAbbreviationRepository journalAbbreviationRepository = JournalAbbreviationLoader.loadRepository(preferences.getJournalAbbreviationPreferences());
162168
Injector.setModelOrService(BibEntryTypesManager.class, entryTypesManager);

jabgui/src/main/java/org/jabref/gui/actions/ActionHelper.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import javafx.collections.ObservableList;
1111

1212
import org.jabref.gui.StateManager;
13-
import org.jabref.logic.git.GitHandler;
1413
import org.jabref.logic.git.util.GitHandlerRegistry;
1514
import org.jabref.logic.preferences.CliPreferences;
1615
import org.jabref.logic.shared.DatabaseLocation;
@@ -20,6 +19,7 @@
2019
import org.jabref.model.entry.LinkedFile;
2120
import org.jabref.model.entry.field.Field;
2221

22+
import com.airhacks.afterburner.injection.Injector;
2323
import com.tobiasdiez.easybind.EasyBind;
2424
import com.tobiasdiez.easybind.EasyBinding;
2525

@@ -112,11 +112,10 @@ public static BooleanExpression needsGitRemoteConfigured(StateManager stateManag
112112
EasyBind.map(stateManager.activeDatabaseProperty(), contextOptional -> {
113113
if (contextOptional.isPresent()) {
114114
return contextOptional.get().getDatabasePath()
115-
.map(path -> {
116-
GitHandler handler = new GitHandlerRegistry().get(path.getParent());
117-
return handler != null && handler.hasRemote("origin");
118-
})
119-
.orElse(false);
115+
.flatMap(path -> Injector.instantiateModelOrService(GitHandlerRegistry.class).fromAnyPath(path))
116+
.map(handler -> handler.hasRemote("origin")
117+
)
118+
.orElse(false);
120119
} else {
121120
return false;
122121
}

jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.jabref.gui.welcome.WelcomeTab;
5656
import org.jabref.logic.UiCommand;
5757
import org.jabref.logic.ai.AiService;
58+
import org.jabref.logic.git.util.GitHandlerRegistry;
5859
import org.jabref.logic.journals.JournalAbbreviationRepository;
5960
import org.jabref.logic.util.BuildInfo;
6061
import org.jabref.logic.util.TaskExecutor;
@@ -102,6 +103,7 @@ private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR }
102103
private final BibEntryTypesManager entryTypesManager;
103104
private final ClipBoardManager clipBoardManager;
104105
private final TaskExecutor taskExecutor;
106+
private final GitHandlerRegistry gitHandlerRegistry;
105107

106108
private final JabRefFrameViewModel viewModel;
107109
private final GuiPushToApplicationCommand pushToApplicationCommand;
@@ -125,7 +127,8 @@ public JabRefFrame(Stage mainStage,
125127
CountingUndoManager undoManager,
126128
BibEntryTypesManager entryTypesManager,
127129
ClipBoardManager clipBoardManager,
128-
TaskExecutor taskExecutor) {
130+
TaskExecutor taskExecutor,
131+
GitHandlerRegistry gitHandlerRegistry) {
129132
this.mainStage = mainStage;
130133
this.dialogService = dialogService;
131134
this.fileUpdateMonitor = fileUpdateMonitor;
@@ -136,6 +139,7 @@ public JabRefFrame(Stage mainStage,
136139
this.entryTypesManager = entryTypesManager;
137140
this.clipBoardManager = clipBoardManager;
138141
this.taskExecutor = taskExecutor;
142+
this.gitHandlerRegistry = gitHandlerRegistry;
139143

140144
setId("frame");
141145

@@ -246,7 +250,8 @@ private void initLayout() {
246250
clipBoardManager,
247251
this::getOpenDatabaseAction,
248252
aiService,
249-
entryEditor);
253+
entryEditor,
254+
gitHandlerRegistry);
250255

251256
VBox head = new VBox(mainMenu, mainToolBar);
252257
head.setSpacing(0d);

jabgui/src/main/java/org/jabref/gui/frame/MainMenu.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import org.jabref.gui.util.URLs;
8282
import org.jabref.gui.util.UiTaskExecutor;
8383
import org.jabref.logic.ai.AiService;
84+
import org.jabref.logic.git.util.GitHandlerRegistry;
8485
import org.jabref.logic.help.HelpFile;
8586
import org.jabref.logic.importer.IdFetcher;
8687
import org.jabref.logic.importer.WebFetchers;
@@ -111,6 +112,7 @@ public class MainMenu extends MenuBar {
111112
private final Supplier<OpenDatabaseAction> openDatabaseActionSupplier;
112113
private final AiService aiService;
113114
private final PreviewControls previewControls;
115+
private final GitHandlerRegistry gitHandlerRegistry;
114116

115117
public MainMenu(JabRefFrame frame,
116118
FileHistoryMenu fileHistoryMenu,
@@ -127,7 +129,8 @@ public MainMenu(JabRefFrame frame,
127129
ClipBoardManager clipBoardManager,
128130
Supplier<OpenDatabaseAction> openDatabaseActionSupplier,
129131
AiService aiService,
130-
PreviewControls previewControls) {
132+
PreviewControls previewControls,
133+
GitHandlerRegistry gitHandlerRegistry) {
131134
this.frame = frame;
132135
this.fileHistoryMenu = fileHistoryMenu;
133136
this.sidePane = sidePane;
@@ -144,6 +147,7 @@ public MainMenu(JabRefFrame frame,
144147
this.openDatabaseActionSupplier = openDatabaseActionSupplier;
145148
this.aiService = aiService;
146149
this.previewControls = previewControls;
150+
this.gitHandlerRegistry = gitHandlerRegistry;
147151

148152
createMenu();
149153
}
@@ -185,8 +189,8 @@ private void createMenu() {
185189
// TODO: Should be only enabled if not yet shared.
186190
factory.createSubMenu(StandardActions.GIT,
187191
factory.createMenuItem(StandardActions.GIT_COMMIT, new GitCommitAction(dialogService, stateManager)),
188-
factory.createMenuItem(StandardActions.GIT_PULL, new GitPullAction(dialogService, stateManager, preferences, taskExecutor)),
189-
factory.createMenuItem(StandardActions.GIT_PUSH, new GitPushAction(dialogService, stateManager, preferences, taskExecutor)),
192+
factory.createMenuItem(StandardActions.GIT_PULL, new GitPullAction(dialogService, stateManager, preferences, taskExecutor, gitHandlerRegistry)),
193+
factory.createMenuItem(StandardActions.GIT_PUSH, new GitPushAction(dialogService, stateManager, preferences, taskExecutor, gitHandlerRegistry)),
190194
new SeparatorMenuItem(),
191195
factory.createMenuItem(StandardActions.GIT_SHARE, new GitShareToGitHubAction(dialogService, stateManager))
192196
),

jabgui/src/main/java/org/jabref/gui/git/GitCommitDialogView.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import org.jabref.gui.DialogService;
99
import org.jabref.gui.StateManager;
10-
import org.jabref.gui.preferences.GuiPreferences;
1110
import org.jabref.gui.util.BaseDialog;
1211
import org.jabref.gui.util.IconValidationDecorator;
12+
import org.jabref.logic.git.util.GitHandlerRegistry;
1313
import org.jabref.logic.l10n.Localization;
1414
import org.jabref.logic.util.TaskExecutor;
1515

@@ -30,10 +30,10 @@ public class GitCommitDialogView extends BaseDialog<Void> {
3030
@Inject
3131
private DialogService dialogService;
3232

33-
@Inject
34-
private GuiPreferences preferences;
3533
@Inject
3634
private TaskExecutor taskExecutor;
35+
@Inject
36+
private GitHandlerRegistry gitHandlerRegistry;
3737

3838
private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer();
3939

@@ -46,7 +46,7 @@ public GitCommitDialogView() {
4646
@FXML
4747
private void initialize() {
4848
setTitle(Localization.lang("Git Commit"));
49-
this.viewModel = new GitCommitDialogViewModel(stateManager, dialogService, taskExecutor);
49+
this.viewModel = new GitCommitDialogViewModel(stateManager, dialogService, taskExecutor, gitHandlerRegistry);
5050

5151
commitMessage.textProperty().bindBidirectional(viewModel.commitMessageProperty());
5252
commitMessage.setPromptText(Localization.lang("Enter commit message here"));

jabgui/src/main/java/org/jabref/gui/git/GitCommitDialogViewModel.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class GitCommitDialogViewModel extends AbstractViewModel {
3333
private final StateManager stateManager;
3434
private final DialogService dialogService;
3535
private final TaskExecutor taskExecutor;
36+
private final GitHandlerRegistry gitHandlerRegistry;
3637

3738
private final StringProperty commitMessage = new SimpleStringProperty("");
3839
private final BooleanProperty amend = new SimpleBooleanProperty(false);
@@ -42,10 +43,12 @@ public class GitCommitDialogViewModel extends AbstractViewModel {
4243
public GitCommitDialogViewModel(
4344
StateManager stateManager,
4445
DialogService dialogService,
45-
TaskExecutor taskExecutor) {
46+
TaskExecutor taskExecutor,
47+
GitHandlerRegistry gitHandlerRegistry) {
4648
this.stateManager = stateManager;
4749
this.dialogService = dialogService;
4850
this.taskExecutor = taskExecutor;
51+
this.gitHandlerRegistry = gitHandlerRegistry;
4952

5053
this.commitMessageValidator = new FunctionBasedValidator<>(
5154
commitMessage,
@@ -90,13 +93,12 @@ private void doCommit() throws JabRefException, GitAPIException, IOException {
9093
}
9194

9295
Path bibFilePath = bibFilePathOpt.get();
93-
GitHandlerRegistry registry = new GitHandlerRegistry();
9496
Optional<Path> repoRootOpt = GitHandler.findRepositoryRoot(bibFilePath);
9597
if (repoRootOpt.isEmpty()) {
9698
throw new JabRefException(Localization.lang("Commit aborted: Path is not inside a Git repository."));
9799
}
98100

99-
GitHandler gitHandler = registry.get(repoRootOpt.get());
101+
GitHandler gitHandler = gitHandlerRegistry.get(repoRootOpt.get());
100102

101103
GitStatusSnapshot status = GitStatusChecker.checkStatus(gitHandler);
102104
if (!status.tracking()) {

jabgui/src/main/java/org/jabref/gui/git/GitPullAction.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.jabref.model.database.BibDatabaseContext;
2525
import org.jabref.model.entry.BibEntry;
2626

27-
import com.airhacks.afterburner.injection.Injector;
2827
import org.eclipse.jgit.api.errors.GitAPIException;
2928

3029
public class GitPullAction extends SimpleCommand {
@@ -33,15 +32,18 @@ public class GitPullAction extends SimpleCommand {
3332
private final StateManager stateManager;
3433
private final GuiPreferences guiPreferences;
3534
private final TaskExecutor taskExecutor;
35+
private final GitHandlerRegistry gitHandlerRegistry;
3636

3737
public GitPullAction(DialogService dialogService,
3838
StateManager stateManager,
3939
GuiPreferences guiPreferences,
40-
TaskExecutor taskExecutor) {
40+
TaskExecutor taskExecutor,
41+
GitHandlerRegistry gitHandlerRegistry) {
4142
this.dialogService = dialogService;
4243
this.stateManager = stateManager;
4344
this.guiPreferences = guiPreferences;
4445
this.taskExecutor = taskExecutor;
46+
this.gitHandlerRegistry = gitHandlerRegistry;
4547

4648
this.executable.bind(ActionHelper.needsDatabase(stateManager).and(ActionHelper.needsGitRemoteConfigured(stateManager)));
4749
}
@@ -69,11 +71,10 @@ public void execute() {
6971

7072
Path bibFilePath = bibFilePathOpt.get();
7173

72-
GitHandlerRegistry registry = Injector.instantiateModelOrService(GitHandlerRegistry.class);
73-
GitStatusViewModel gitStatusViewModel = GitStatusViewModel.fromPathAndContext(stateManager, taskExecutor, registry, bibFilePath);
74+
GitStatusViewModel gitStatusViewModel = GitStatusViewModel.fromPathAndContext(stateManager, taskExecutor, gitHandlerRegistry, bibFilePath);
7475

7576
BackgroundTask
76-
.wrap(() -> doPull(activeDatabase, bibFilePath, stateManager, registry))
77+
.wrap(() -> doPull(activeDatabase, bibFilePath, gitHandlerRegistry))
7778
.onSuccess(result -> {
7879
if (result.noop()) {
7980
dialogService.showInformationDialogAndWait(
@@ -92,11 +93,11 @@ public void execute() {
9293
}
9394
}
9495
})
95-
.onFailure(exception -> showPullError(exception))
96+
.onFailure(this::showPullError)
9697
.executeWith(taskExecutor);
9798
}
9899

99-
private PullResult doPull(BibDatabaseContext databaseContext, Path bibPath, StateManager stateManager, GitHandlerRegistry registry) throws IOException, GitAPIException, JabRefException {
100+
private PullResult doPull(BibDatabaseContext databaseContext, Path bibPath, GitHandlerRegistry registry) throws IOException, GitAPIException, JabRefException {
100101
GitSyncService syncService = buildSyncService(bibPath, registry);
101102
GitHandler handler = registry.get(bibPath.getParent());
102103
String user = guiPreferences.getGitPreferences().getUsername();
@@ -105,7 +106,7 @@ private PullResult doPull(BibDatabaseContext databaseContext, Path bibPath, Stat
105106
return syncService.fetchAndMerge(databaseContext, bibPath);
106107
}
107108

108-
private GitSyncService buildSyncService(Path bibPath, GitHandlerRegistry handlerRegistry) throws JabRefException {
109+
private GitSyncService buildSyncService(Path bibPath, GitHandlerRegistry handlerRegistry) {
109110
GitConflictResolverDialog dialog = new GitConflictResolverDialog(dialogService, guiPreferences);
110111
GitConflictResolverStrategy resolver = new GuiGitConflictResolverStrategy(dialog);
111112
GitSemanticMergeExecutor mergeExecutor = new GitSemanticMergeExecutorImpl(guiPreferences.getImportFormatPreferences());

0 commit comments

Comments
 (0)