-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add simple git support #12817
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
Add simple git support #12817
Conversation
…and to pull latest changes if so
Update GitHandler constructor to optionally not create a repository if none exists
…gui.importer.actions
…d-pull' into library-under-version-control-and-pull # Conflicts: # src/test/java/org/jabref/gui/importer/actions/CheckForVersionControlActionTest.java
removed the logic that required the download of additional libraries/dependencies
…into Happy-Days-Git-Integration-WP3
…ion-control-and-pull
…eneral for autopush - to be cleaned up
…d-pull' into library-under-version-control-and-pull # Conflicts: # src/main/java/org/jabref/logic/preferences/CliPreferences.java
…-Git-Integration-WP3
You can go to the previous commits. We discussed that shortly in the meeting, but did not have time to dig deeper. |
OK, then let's focus on the PRs in that order. After a PR is squash-merged, you can follow the howto on flupp.de on how to merge I ask you to work on #12678 to get the unit tests fixed. Our maintainers do all of this in their spare time - and like more to work on pull requests with green tests. |
…/jabref into Add-Simple-Git-Support
|
||
boolean result = action.isActionNecessary(parserResult, dialogService, cliPreferences); | ||
|
||
assertTrue(result); |
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.
Assertion statements should not include the message parameter, and the method name should already convey the expected behavior. This violates the guideline for assertion statements.
|
||
boolean result = action.isActionNecessary(parserResult, dialogService, cliPreferences); | ||
|
||
assertFalse(result); |
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.
Assertion statements should not include the message parameter, and the method name should already convey the expected behavior. This violates the guideline for assertion statements.
|
||
action.isActionNecessary(parserResult, dialogService, cliPreferences); | ||
|
||
assertDoesNotThrow(() -> action.performAction(parserResult, dialogService, 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.
Assertion statements should not include the message parameter, and the method name should already convey the expected behavior. This violates the guideline for assertion statements.
- Create NotificationService interface in Logic layer - Implement DialogNotificationService adapter in GUI layer - Replace direct DialogService dependency with NotificationService in GitClientHandler - Update all call sites to use the new adapter pattern - Add missing localization keys for Git operations - Remove obsolete localization key This change resolves architectural layering violations while maintaining enhanced error handling and user feedback for Git operations. It properly separates Logic and GUI layers, following the dependency inversion principle.
…/jabref into Add-Simple-Git-Support
alright! Understood- we are submitting our university project today, will follow up with fixing the unit testing |
Merge remote-tracking branch 'origin/Add-Simple-Git-Support' into Add-Simple-Git-Support
@@ -396,7 +409,8 @@ private boolean isDatabaseReadyForBackup(BibDatabaseContext context) { | |||
* <p> | |||
* Example: *jabref-authors.bib – testbib | |||
*/ | |||
public void updateTabTitle(boolean isChanged) { | |||
|
|||
public void updateTabTitle(boolean isModified) { |
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 method updateTabTitle has been modified but lacks JavaDoc to explain its purpose and behavior, especially after the changes related to Git integration.
@@ -53,6 +53,9 @@ public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> i | |||
@FXML private CheckBox alwaysReformatBib; | |||
@FXML private CheckBox autosaveLocalLibraries; | |||
@FXML private Button autosaveLocalLibrariesHelp; | |||
@FXML private TextField gitHubUsernameField; |
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 new UI elements for GitHub integration, such as gitHubUsernameField, should have their labels localized using Localization.lang(). This ensures consistency with other UI elements.
@@ -440,4 +451,16 @@ private Optional<Integer> getPortAsInt(String value) { | |||
return Optional.empty(); | |||
} | |||
} | |||
|
|||
public BooleanProperty autoPushEnabledProperty() { |
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 method 'autoPushEnabledProperty' returns a BooleanProperty, which can potentially be null. New public methods should not return null and should use java.util.Optional instead.
return gitPreferences.getAutoPushEnabledProperty(); | ||
} | ||
|
||
public StringProperty gitHubUsernameProperty() { |
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 method 'gitHubUsernameProperty' returns a StringProperty, which can potentially be null. New public methods should not return null and should use java.util.Optional instead.
return gitPreferences.gitHubUsernameProperty(); | ||
} | ||
|
||
public StringProperty gitHubPasskeyProperty() { |
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 method 'gitHubPasskeyProperty' returns a StringProperty, which can potentially be null. New public methods should not return null and should use java.util.Optional instead.
try { | ||
pushCommitsToRemoteRepository(); | ||
} catch (IOException e) { | ||
LOGGER.error("Failed to push"); |
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 exception is not logged using exception logging capabilities, which would provide more context about the error. It should include the exception object.
} catch (IOException e) { | ||
LOGGER.error("Failed to get latest commit"); | ||
} | ||
return null; |
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.
Returning null from a method is discouraged. Instead, java.util.Optional should be used to avoid potential NullPointerExceptions.
* @param repositoryPath The root of the initialized git repository | ||
* @param createRepo If true, initializes a repository if the file path does not contain a repository | ||
*/ | ||
public GitHandler(Path repositoryPath, boolean createRepo) { |
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 constructor has a boolean parameter 'createRepo'. Boolean parameters should be avoided in public methods. Consider creating two distinct methods for clarity.
} catch (GitAPIException e) { | ||
LOGGER.info("Failed to push"); | ||
LOGGER.error("Failed to push: {}", e.getMessage(), 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.
The logging statement should use exception logging capabilities directly without concatenating the exception message.
} catch (GitAPIException e) { | ||
LOGGER.info("Failed to push"); | ||
LOGGER.error("Failed to pull", 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.
The logging statement should use exception logging capabilities directly without concatenating the exception message.
JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output. 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. |
Closes #12350
We have implemented code here in 3 working packages (denoted 'WP' here).
WP1 - check if a .bib file (used in bibliography management) is inside a Git
repository. If it is, it tags the file as “versioned” and performs a git pull to fetch the latest
updates from the repository.
WP2 - Display the status of synchronisation with the file name.

WP3 - Allow the user to enable an auto push on save functionality via the general preferences as well as enable manual git support for simple git pull/push functionality. With appropriate dialogs for each instance.

The changes we have made on a class by class basis:
GitHandler
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)