-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use git for backup #12252
base: main
Are you sure you want to change the base?
Use git for backup #12252
Conversation
.gitmodules
Outdated
@@ -13,3 +13,6 @@ | |||
url = https://github.com/citation-style-language/locales.git | |||
ignore = all | |||
shallow = true | |||
[submodule "jabref"] |
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.
Revert this change
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.
and also fix the other submodule issues.
You probably have to first sync your main branch with the latest changes from upstream and then your branch
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.
Hello ! I am sorry for the late reply. I applied what is written here https://devdocs.jabref.org/code-howtos/faq.html#submodules to fix the submodules, it worked correctly because I no more have local changes when I execute : git checkout main -- src/main/resources/csl-styles, still, the problem with the submodule csl-styles doesn't seem to be resolved. And can you tell me what changes am I supposed to adress in the CHANGELOG (we already added the suggested edits from the last month, but there is still some changes required by the PR).
@khola22 we will be making sure your feature is a part of the 6.0-beta release. Thanks for so much patience, it's just that the maintainers are a bit busy with a couple of things (and other urgent issues) at the moment. We'll provide more feedback as soon as we can. |
# Conflicts: # src/main/resources/csl-locales # src/main/resources/csl-styles
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import.
You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.
To ease organizational workflows I have linked the pull-request to the issue with syntax as described in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
Example:
|
Submodule config got messed up:
I try to find out how to fix - will be difficult. |
Hint https://www.deployhq.com/support/common-repository-errors/no-url-found-for-submodule (found via Google) |
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.
I started to dive into the code, but some basic non-code conventions distracted me. Please try to fix them. They might seem to be trivial for you, but I would need several minutes for it, but I currently don't have time to do these kind of tasks. I need time for feedback on a higher level.
LOGGER.info("Database file uniquely copied to backup directory: {}", backupFilePath); | ||
} | ||
|
||
// A method |
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.
This comment can be removed.
LOGGER.info("Successfully rewrote the file at path: {}", dbFile); | ||
} | ||
|
||
// Helper method to normalize BibTeX content |
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.
Convert to JAvaDoc - ALL comments to Methods have to be JavaDoc
The WHY is missing the comment -why is this needed?
* @param backupDir the backup directory | ||
* @param objectId the commit ID to restore from | ||
*/ | ||
|
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.
JavaDoc and method begin should be kept together - please remove all empty lines between JavaDoc and method.
if (needsBackup) { | ||
LOGGER.info("Backup needed, because needsBackup is :{}", needsBackup); | ||
} else { | ||
LOGGER.info("Backup needed, because needsCommit is :{}", needsCommit); |
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.
indent is wrong. I wonder why our checkstyle did not comlain here.
} | ||
|
||
if (needsBackup) { | ||
LOGGER.info("Backup needed, because needsBackup is :{}", needsBackup); |
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.
LOGGER.info("Backup needed, because needsBackup is :{}", needsBackup); | |
LOGGER.info("Backup needed, because needsBackup is: {}", needsBackup); |
Please use Amercian positioning of spaces and colon: First comes the colon, then the space.
String content = Localization.lang("It looks like JabRef did not shut down cleanly last time the file was used.") + "\n\n" + | ||
Localization.lang("Do you want to recover the library from a backup file?"); |
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.
Merge this into one string!
(Even though in the original, newlines were also split like this, but this is wrong)
Note that I renamed "BackupManagerGit" to "BackupManager" as the "old" BackupManager is gone. No need to create a new class. Keeping the base class name also simplifies reviewing. |
@koppor Thanks for diving into the code! I've just made the necessary changes to address the non-code conventions you mentioned. Let us know if there's anything else we can improve! |
|
||
|
||
|
||
|
||
|
||
|
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.
Remove all except one empty line
src/main/resources/csl-styles
Outdated
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.
Sync submodules (it's happening repeatedly so please read the "prevention section in the faq - https://devdocs.jabref.org/code-howtos/faq.html#prevention)
// copyDatabaseFileToBackupDir(dbFile, backupDir); | ||
|
||
// Ensure the Git repository exists | ||
LOGGER.info("Ensuring the .git is initialized"); |
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.
Reduce log noise. Maybe use Logger.debug
LOGGER.info("Committed content: {}", committedContent); | ||
LOGGER.info("Current content: {}", currentContent); |
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.
If you are done using this for logging, remove or use debug mode
if (action.isActionNecessary(result, dialogService, preferences)) { | ||
LOGGER.info("Action is necessary"); |
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.
Copy above review comments for all logger.infos
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 a bit late, but howtos for logging in JabRef are written at https://devdocs.jabref.org/code-howtos/logging.html
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.
The important line is
[email protected] = debug
In this way, you can read all your log infos while developing
Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues. |
.onSuccess(result -> { | ||
try { | ||
newTab.onDatabaseLoadingSucceed(result); | ||
} catch (Exception e) { |
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.
Catches general Exception instead of specific exceptions (GitAPIException and IOException). This violates the principle of catching specific exceptions only.
@@ -343,7 +344,7 @@ private void onDatabaseLoadingFailed(Exception ex) { | |||
dialogService.showErrorDialogAndWait(title, content, ex); | |||
} | |||
|
|||
private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) { | |||
private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) throws GitAPIException, IOException { |
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 signature changed to throw exceptions but JavaDoc wasn't updated to reflect these changes. When method changes, its documentation must be updated accordingly.
I tried to merge The diff shows
Some "useless JavaDoc entries (they are derived from the name directly not adding any new informatoin)
The diff for CHANGELOG.md is also larger than it should Following is bad style
I think, we had the Normalization of BibTeX is not done using the LineEndingNormalizer or the bibtex saver itself (which normalizes internally), but differently. Seeing all this, I think, the core team needs to take over |
Yes the feature is really promising and the team around the op did already a great job, but now it comes to leveraging this huge project to make it mergable. We can maybe put this in our milestone for the next beta. |
Fiixes #2961
This PR introduces several key updates and improvements aimed at enhancing the backup management, change detection, and UI functionalities.
Backup Management with Git Integration:
A new BackupManagerGit class has been implemented to handle backups using Git. This allows .bib files to be automatically copied to a dedicated jabref/backups directory every 19 seconds, ensuring that a comprehensive commit history is maintained via Git. This approach provides a centralized and version-controlled backup mechanism, independent of the file location.
Change Detection Logic:
Change detection is now triggered when .bib files are overwritten during explicit user actions such as Save, Save All, or the save prompts when exiting the application. While listeners continue to track edits, their strict conditions occasionally limit their ability to dynamically detect changes. As a result, we face two challenges:
Lack of autosave functionality without user interaction.
Potential failure to record unsaved changes if the application closes unexpectedly.
UI Enhancements:
The UI has been updated to provide functionality for saving, committing, and discarding changes, along with accurate commit details retrieval. While most features are working as expected, challenges remain with the checkout functionality, especially when reverting commits using JGit. We welcome feedback on this part of the implementation.
Date of backup refers to the date of the commit.
Code Refactoring and Adaptation:
We’ve refactored various components to integrate with BackupManagerGit, replacing the older BackupManager logic. Existing classes like CoarseChangeFilter have been retained without modification, as our focus was on implementing the new Git-based backup mechanism.
PS 1: We have retained the BackupManager class for reference, allowing us to review its contents should further clarification of the backup logic be necessary. However, we have ensured that this class is no longer used outside of the specific tests previously dedicated to it, and we have confirmed that BackupManagerGit is the primary class in operation. Despite these precautions, we have encountered an issue with the legacy backup tracking method. Specifically, we have observed occasional, unexpected creation of .bak files within the backup directory. This anomaly has occurred only once during testing. While we suspect the issue may be linked to the UI components of the code, we have yet to pinpoint the precise cause.
PS 2: A potential issue arose concerning the handling of two .bib files with identical names. Copying such files into the repository would result in one file overwriting the other, which is problematic. We are currently investigating a solution to this before finalizing the PR for review.
PS 3 : We didn't implement squashing older backup commits.
Update 1: The issue identified in PS 2 has been addressed by implementing UUID-generated unique file names. However, when a .bib file is relocated, a new UUID is generated, which results in a new file being recorded in the Git repository. To resolve this, we propose the following solutions: 1/ Move the .uuid file along with the .bib file when the move is performed through JabRef. 2/ Utilize a file system watcher to track and handle file movements performed outside of JabRef.
Updates 2 : Restore button works.
We have not yet pursued further investigation into these solutions.
The title of the isuue : Enhanced backup restore dialog #2961
The link of the issue : #2961 (comment)
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)