-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Git Integration and UI Improvements #12252
base: main
Are you sure you want to change the base?
Conversation
hello @subhramit , we were trying to resolve the conflicts with submodules as said in the link, the first approache didn't work, but for the second one, we have an issue :
|
Update : we fixed the conflicts relative to submodules. |
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.
Initial suggestions.
@calixtus I'd want you to take a look at the usage of 1. preferences 2. mockito in this PR once. I remember using RETURN_DEEP_STUBS for some preference in the past, the use case seems similar here. However, I think we can reduce the usage of mockito for other cases by using concrete instantiations (entries, database context, database, entrytypesmanager in particular).
CHANGELOG.md
Outdated
@@ -11,6 +11,11 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv | |||
|
|||
### Added | |||
|
|||
- Implemented BackupManagerGit to handle automatic backups of .bib files using Git, ensuring centralized, version-controlled backup management. [#2961](https://github.com/JabRef/jabref/issues/2961) |
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.
Changelog entries are primarily for users, so they are not supposed to be aware of internal implementations or class names ("BackupManagerGit"). Just mention git-based version control. Ideally make entries short and crisp as well. For example:
- Implemented BackupManagerGit to handle automatic backups of .bib files using Git, ensuring centralized, version-controlled backup management. [#2961](https://github.com/JabRef/jabref/issues/2961) | |
- Implemented version-control based backup management of .bib files using Git. [#2961](https://github.com/JabRef/jabref/issues/2961) |
CHANGELOG.md
Outdated
@@ -11,6 +11,11 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv | |||
|
|||
### Added | |||
|
|||
- Implemented BackupManagerGit to handle automatic backups of .bib files using Git, ensuring centralized, version-controlled backup management. [#2961](https://github.com/JabRef/jabref/issues/2961) | |||
- Added automatic copying of .bib files to a jabref/backups directory every 19 seconds with comprehensive commit history. [#2961](https://github.com/JabRef/jabref/issues/2961) | |||
- Added support for unique file naming using UUIDs to prevent overwriting files with identical names in the backup directory. [#2961](https://github.com/JabRef/jabref/issues/2961) |
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.
Part of internal implementation of the introduced feature and not a "change" from existing release. Remove this.
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.
@khola22 Please do not mark review comments as resolved (except if it is trivially visible that it has been resolved). In this case, this was asked to be removed, and it is not (yet).
Once you push fresh commits on the code window, this will automatically be marked "Outdated". Then, one of the maintainers can take a look and mark them resolved.
This also allows for conversations in case you get stuck in a particular comment's context or amongst maintainers if there's any change of plans or someone suggests a better idea.
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.
@subhramit okay ! sorry about that .
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.
@subhramit okay ! sorry about that .
No issues, and no need to be sorry. It's on us to guide new contributors!
CHANGELOG.md
Outdated
- Implemented BackupManagerGit to handle automatic backups of .bib files using Git, ensuring centralized, version-controlled backup management. [#2961](https://github.com/JabRef/jabref/issues/2961) | ||
- Added automatic copying of .bib files to a jabref/backups directory every 19 seconds with comprehensive commit history. [#2961](https://github.com/JabRef/jabref/issues/2961) | ||
- Added support for unique file naming using UUIDs to prevent overwriting files with identical names in the backup directory. [#2961](https://github.com/JabRef/jabref/issues/2961) | ||
- Introduced UI functionality (only during opening) for saving, restoring, reviewing and discarding changes with accurate commit details retrieval. [#2961](https://github.com/JabRef/jabref/issues/2961) |
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.
Part of the introduced feature (also pertains to the same issue). Remove this as well.
CHANGELOG.md
Outdated
- Added automatic copying of .bib files to a jabref/backups directory every 19 seconds with comprehensive commit history. [#2961](https://github.com/JabRef/jabref/issues/2961) | ||
- Added support for unique file naming using UUIDs to prevent overwriting files with identical names in the backup directory. [#2961](https://github.com/JabRef/jabref/issues/2961) | ||
- Introduced UI functionality (only during opening) for saving, restoring, reviewing and discarding changes with accurate commit details retrieval. [#2961](https://github.com/JabRef/jabref/issues/2961) | ||
- Enabled a "Restore" button to recover specific backup versions. [#2961](https://github.com/JabRef/jabref/issues/2961) |
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.
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.
Some user facing information should be kept, e.g. "enhanced backup and restore functionality".
CHANGELOG.md
Outdated
@@ -52,6 +57,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv | |||
|
|||
### Changed | |||
|
|||
- Refactored backup-related components to integrate with the new BackupManagerGit, replacing the older BackupManager logic. [#2961](https://github.com/JabRef/jabref/issues/2961) |
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.
Internal implementation, not relevant to user-side. Remove.
String normalized = lines | ||
.map(String::trim) // Supprimer les espaces en début et fin de ligne | ||
.filter(line -> !line.isBlank()) // Supprimer les lignes vides | ||
.collect(Collectors.joining("\n")); // Réassembler avec des sauts de ligne |
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.
Avoid magic strings. Put \n
into a constant named LINE_BREAK
.
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.
OS.NEWLINE
mockDatabaseContext1 = mock(BibDatabaseContext.class); | ||
mockDatabaseContext2 = mock(BibDatabaseContext.class); |
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.
You don't need to mock multiple instances of the same class.
If you actually want variation, make different entries/set of entries and generate a database context from them.
mockLibraryTab = mock(LibraryTab.class); | ||
mockDatabaseContext1 = mock(BibDatabaseContext.class); | ||
mockDatabaseContext2 = mock(BibDatabaseContext.class); | ||
mockEntryTypesManager = mock(BibEntryTypesManager.class); |
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.
You can make an actual instance instead of mocking this.
.map(Path::toFile) | ||
.forEach(file -> { | ||
if (!file.delete()) { | ||
file.deleteOnExit(); |
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.
@koppor Not sure about this one, I think using @TempDir
would take care of the deletion?
GuiPreferences preferences, | ||
List<BackupEntry> backups) { | ||
return UiTaskExecutor.runInJavaFXThread( | ||
() -> dialogService.showCustomDialogAndWait(new BackupChoiceDialog(preferences.getFilePreferences().getBackupDirectory(), backups))); |
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.
Pass preferences.getFilePreferences().getBackupDirectory()
via constructor and use it here for better abstraction (detailed reason in similar review comment above).
Also, is this supposed to be GuiPreferences or CliPreferences?
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.
Its fine in the FilePreferences/GuiPreferences. You only need the backup in the ui mode.
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.
Its fine in the FilePreferences/GuiPreferences. You only need the backup in the ui mode.
The rest of their changes involve clipreferences
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.
guipreferences is a superset of clipreferences.
By the way, really good work guys. Please also take a look at the failing tests and try to fix them. |
Co-authored-by: Subhramit Basu Bhowmick <[email protected]>
Hey team, good job fixing the tests. |
Hello @subhramit , |
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)