Description
As user, I would like to have a seamless integration in git. For "straight-forward" cases, JabRef should do "magic".
Implementation drivers
- In case of an error, the file should be in the state before JabRef started to do some wizard thing
Opening a library
- When opening a library (.bib file), JabRef checks whether the .bib file is contained in a git repository. If not in a git repository, no further action is done. Otherwise it is tagged as "versioned" (BibDatabaseContext)
- JabRef exetues a "git pull" to update the .bib file
- If error: notification of error, revert file to previous state
- JabRef opens the updated file
Saving of a library
No action taken (to save number of commits)
Saving a library
- JabRef saves the .bib file
- A git commit is created. git commit message "Automatic update via JabRef".
Just executegit pull --rebase
is executed.git pull
In case of an error, revert to commit created at step 2 and trygit pull
- In case of an error, revert to commit created at step 2 and ouput a notification - and stop
- Then,
git push
- In case of an error, output error - and stop
- Output "Successfully pushed"
Advanced implementation
A user might want to trigger pushing
- Reuse button "synchronize" of shared database. This button has the same functionality as "Saving a library"
- Let user configure frequency of push. At this frequence, on "Saving a library", a commit and the steps of "Saving a library" are done.
Implementation hints
- Working with JGit in general: https://github.com/koppor/jgit-mwe
- Git in JabRef: Start at org.jabref.logic.git.GitHandlerTest - and then read on at org.jabref.logic.git.GitHandler
- Please, start with http-based repositories: username + password. For GitHub, the password is a "personal access token". See https://github.com/koppor/jgit-mwe?tab=readme-ov-file#run-with-credentials.
- Some ideas can be taken from Add git support #10586 (e.g., how to work with preferences)