-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Implement logic orchestration for Git Pull/Push operations #13518
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?
Conversation
jabgui/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java
Outdated
Show resolved
Hide resolved
@@ -27,7 +27,7 @@ public interface LibraryTabContainer { | |||
* Closes a designated libraryTab | |||
* | |||
* @param tab to be closed. | |||
* @return true if closing the tab was successful | |||
* @return true if closing the tab was isSuccessful |
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.
IntelliJ probably replaced this
* @return true if closing the tab was isSuccessful | |
* @return true if closing the tab was successful |
…esolver interface to the logic module) JabRef#12350
8302ebc
to
32c30a0
Compare
…remote main branch exists JabRef#12350
// Status is BEHIND or DIVERGED | ||
try (Git git = gitHandler.open()) { |
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.
Comment is trivial and can be derived from the code context. The status check above clearly indicates this is for BEHIND or DIVERGED cases.
// Debug hint: Show the created git graph on the command line | ||
// git log --graph --oneline --decorate --all --reflog |
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.
Commented code should be removed as per project guidelines. Git history should be used instead of keeping debug hints in comments.
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.
Will remove in the end
…jabref into clean-gsoc-git-support-init
* 3. Alice update a → pull | ||
*/ | ||
@BeforeEach | ||
void aliceBobSimple(@TempDir Path tempDir) throws Exception { |
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.
Method name contains typo in comment 'alieBobSetting' vs actual name 'aliceBobSimple', violating consistent and correct naming conventions in code.
JUnit tests of You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide. |
import static org.mockito.Mockito.when; | ||
|
||
class GitSyncServiceTest { | ||
private Git git; |
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.
Maybe name this aliceGit
to be consistent with @BeforeEach
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
GitSyncService
GitHandler
🔧 Key Methods in
GitSyncService
fetchAndMerge(Path)
performSemanticMerge(...)
.bib
content semantically. UsesSemanticMerger
and conflict resolution strategy.push(Path)
📦 Package:
org.jabref.logic.git.io
This package bridges Git and JabRef's BibTeX data model by handling read/write operations for
.bib
files at specific Git revisions.GitBibParser
.bib
content from a Git commit into aBibDatabaseContext
using JabRef's parser.GitFileReader
.bib
text from a specific Git commit.GitFileWriter
BibDatabaseContext
content back to a.bib
file after merge.GitRevisionLocator
base
,local
, andremote
commits for 3-way merge.RevisionTriple
base
,local
, andremote
revisions.📦 Package:
org.jabref.logic.git.status
Handles detection of Git repository and file tracking/sync status. Used before pull/push to determine the correct operation.
GitStatusChecker
.bib
file and return a snapshot.GitStatusSnapshot
SyncStatus
UP_TO_DATE
,BEHIND
,DIVERGED
, etc.).📦 Package:
org.jabref.logic.git.conflicts
Handles semantic conflict detection and resolution strategies during 3-way merge.
SemanticConflictDetector
BibDatabaseContext
s.ThreeWayEntryConflict
GitConflictResolverStrategy
CliConflictResolverStrategy
Conflict Resolution Flow:
Detect conflicts with
SemanticConflictDetector
.If conflicts exist, invoke a
GitConflictResolverStrategy
:In GUI: use
GuiConflictResolverStrategy
In future CLI: use
CliConflictResolverStrategy
Apply merge plan if resolution succeeds.
📦 Package:
org.jabref.logic.git.merge
Executes semantic 3-way merge operations on
.bib
files, including building merge plans and applying field-level changes.MergePlan
SemanticMerger
MergePlan
to a localBibDatabaseContext
.GitSemanticMergeExecutor
performSemanticMerge()
contract.GitSemanticMergeExecutorImpl
GitMergeUtil
💡 GUI Module Integration Note
GUI dependencies are temporarily introduced to reuse the existing
MergeEntriesDialog
for conflict resolution.This is injected via
GitConflictResolverStrategy
to keep the dependency direction correct (logic → gui).A major UI refactor is WIP.
GuiConflictResolverStrategy
MergeEntriesDialog
to let users manually resolve semantic conflicts inBibEntry
s.Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)