Implement logic orchestration for Git Pull/Push operations#13518
Conversation
…esolver interface to the logic module) JabRef#12350
8302ebc to
32c30a0
Compare
…remote main branch exists JabRef#12350
…jabref into clean-gsoc-git-support-init
|
I think we with Oliver would really like to see this PR merged. So I think you can write new features in the follow up PR 😋 |
|
Regarding the algorithm: Maybe "just" using https://github.com/JabRef/jabref/blob/main/jablib/src/main/java/org/jabref/logic/bibtex/comparator/BibDatabaseDiff.java solves issues? Merging this stats can later help to compare different approaches. Having the approaches here in the PR "hides" them between other discussions. |
Thank you! I’m currently using Only relying on remoteDiffs plus the local map isn’t enough, because it would miss entries that are added or changed only in local. I’ll revise the logic in the follow-up PR |
|
@trag-bot didn't find any issues in the code! ✅✨ |
|
Retested on windows - added some fixes because of eclipse-jgit/jgit#155 (comment) |
|
* upstream/main: Issue 13619 Make Citation relations text more clear. (#13620) Explain how to handle notifications (#13630) Fix scope of 'determine issue number' job (#13627) Add proper closing (#13626) Implement logic orchestration for Git Pull/Push operations (#13518) Make pattern for issue number more strict Fix "Cannot load file MultiMergeEntries.fxml" (#13624) Add Copy markdown to copy citation (#13387) Add ADR-0047 (#13621) Initial start of implementing a LSP for integrity checks (#13612) Refactor merge entries package structure (#13614) New Crowdin updates (#13616) BibEntry class no longer implements Cloneable (#13615) Fix dark mode in {} of Citation Relations tab of the entry editor (#13609) Update dependency org.kohsuke:github-api to v2.0-rc.4 (#13611) Fix setting of proxy without password (#13605)

Closes #12350
Final PR based on draft: JabRef#714
This PR implements the logic-layer orchestration for Git push and pull operations with semantic merging support. It enables JabRef to semantically merge .bib files when possible, avoiding manual conflict resolution for simple changes.
This is part of ongoing work to support full Git-based collaboration for .bib files. Further tests and UI integration are planned.
Steps to test
This PR implements the first part of Git sync support by enabling automatic semantic merges when there are no conflicts. The scenario is tested via TDD in GitSyncServiceTest, simulating the following steps:
Since they changed different entries, we expect a clean merge without user intervention. The orchestrator is GitSyncService, and helper utilities and value objects are temporarily located in org.jabref.logic.git.util.
Documentation Supplement
🧩 Table: Git-related Class Responsibilities
GitSyncServiceGitHandler🔧 Key Methods in
GitSyncServicefetchAndMerge(Path)performSemanticMerge(...).bibcontent semantically. UsesSemanticMergerand conflict resolution strategy.push(Path)📦 Package:
org.jabref.logic.git.ioThis package bridges Git and JabRef's BibTeX data model by handling read/write operations for
.bibfiles at specific Git revisions.GitFileReader.bibtext from a specific Git commit.GitFileWriterBibDatabaseContextcontent back to a.bibfile after merge.GitRevisionLocatorbase,local, andremotecommits for 3-way merge.RevisionTriplebase,local, andremoterevisions.📦 Package:
org.jabref.logic.git.statusHandles detection of Git repository and file tracking/sync status. Used before pull/push to determine the correct operation.
GitStatusChecker.bibfile and return a snapshot.GitStatusSnapshotSyncStatusUP_TO_DATE,BEHIND,DIVERGED, etc.).📦 Package:
org.jabref.logic.git.conflictsHandles semantic conflict detection and resolution strategies during 3-way merge.
SemanticConflictDetectorBibDatabaseContexts.ThreeWayEntryConflictGitConflictResolverStrategyCliConflictResolverStrategyConflict Resolution Flow:
Detect conflicts with
SemanticConflictDetector.If conflicts exist, invoke a
GitConflictResolverStrategy:In GUI: use
GuiConflictResolverStrategyIn future CLI: use
CliConflictResolverStrategyApply merge plan if resolution succeeds.
📦 Package:
org.jabref.logic.git.mergeExecutes semantic 3-way merge operations on
.bibfiles, including building merge plans and applying field-level changes.MergePlanSemanticMergerMergePlanto a localBibDatabaseContext.GitSemanticMergeExecutorperformSemanticMerge()contract.GitSemanticMergeExecutorImplGitMergeUtil💡 GUI Module Integration Note
GUI dependencies are temporarily introduced to reuse the existing
MergeEntriesDialogfor conflict resolution.This is injected via
GitConflictResolverStrategyto keep the dependency direction correct (logic → gui).A major UI refactor is WIP.
GuiConflictResolverStrategyMergeEntriesDialogto let users manually resolve semantic conflicts inBibEntrys.Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)