Skip to content

Commit ac42aa7

Browse files
authored
Restore local-only Git behavior for SLR to fix repository initialization error (#13775)
* Fix SLR study initialization: restore fallback local pull if no remote is configured * Update CHANGELOG.md * Update CHANGELOG.md
1 parent a856625 commit ac42aa7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

jabgui/src/main/java/org/jabref/gui/slr/StartNewStudyAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ protected void crawlPreparation(Path studyRepositoryRoot) throws IOException, Gi
6464
// The GitHandler is already called to initialize the repository with one single commit "Initial commit".
6565
// The "Initial commit" should also contain the created YAML.
6666
// Thus, we append to that commit.
67-
new GitHandler(studyRepositoryRoot).createCommitOnCurrentBranch("Initial commit", true);
67+
GitHandler gitHandler = new GitHandler(studyRepositoryRoot);
68+
gitHandler.initIfNeeded();
69+
gitHandler.createCommitOnCurrentBranch("Initial commit", true);
6870
}
6971

7072
@Override

jablib/src/main/java/org/jabref/logic/git/GitHandler.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,23 +317,19 @@ public void pushCurrentBranchCreatingUpstream() throws IOException, GitAPIExcept
317317
}
318318
}
319319

320+
/// Pulls from the current branch’s upstream.
321+
/// If no remote is configured, silently performs local merge.
322+
/// This ensures SLR repositories without remotes still initialize correctly.
320323
public void pullOnCurrentBranch() throws IOException {
321324
try (Git git = Git.open(this.repositoryPathAsFile)) {
322-
Optional<String> urlOpt = currentRemoteUrl(git.getRepository());
323325
Optional<CredentialsProvider> credsOpt = resolveCredentials();
324-
325-
boolean needCreds = urlOpt.map(GitHandler::requiresCredentialsForUrl).orElse(false);
326-
if (needCreds && credsOpt.isEmpty()) {
327-
throw new IOException("Missing Git credentials (username and Personal Access Token).");
328-
}
329-
330326
PullCommand pullCommand = git.pull();
331327
if (credsOpt.isPresent()) {
332328
pullCommand.setCredentialsProvider(credsOpt.get());
333329
}
334330
pullCommand.call();
335331
} catch (GitAPIException e) {
336-
throw new IOException("Failed to pull from remote: " + e.getMessage(), e);
332+
LOGGER.info("Failed to push");
337333
}
338334
}
339335

0 commit comments

Comments
 (0)