-
-
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
[WIP] Happy days git integration wp3 #12773
base: gitintegration
Are you sure you want to change the base?
[WIP] Happy days git integration wp3 #12773
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
…into Happy-Days-Git-Integration-WP3
- Checkstyle issue in GitPreferences.java fixed. (Incorrect import order) - Broad catch blocks in GitPullAction and GitPushAction fixed - Also fixed incorrect logger usage.
BibDatabaseContext databaseContext = stateManager.getActiveDatabase().get(); | ||
if (stateManager.getActiveDatabase().isEmpty()) { | ||
return; | ||
} |
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.
Potential NPE as get() is called before isEmpty() check. The code retrieves the database before checking if it exists, violating the fail-fast principle and risking exceptions.
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.
Still valid comment
dialogService.showErrorDialogAndWait(e); | ||
} | ||
} else { | ||
LOGGER.info("Not a git repository at path: {}", path.get()); |
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 log message directly calls path.get() without checking if the value is present, which could lead to NoSuchElementException. The Optional should be handled properly.
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.
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.
Just log path, will appear properly. Try it out!
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.
Thank you that works!
- fixed incorrect order of statements for GitPullAction - removed .get() for path in LOGGER statements - checkstyle error fixed - fixed used of a hardcoded path instead of leveraging JUnit's @tempdir annotation.
…into Happy-Days-Git-Integration-WP3
… logic inside a complex if condition. Should check conditions individually and return early if any fails."
… logic inside a complex if condition. Should check conditions individually and return early if any fails."
… logic inside a complex if condition. Should check conditions individually and return early if any fails."
preferences.getAutoPushEnabled()) { | ||
this.updateCredentials(preferences); | ||
try { | ||
this.createCommitOnCurrentBranch("Automatic update via JabRef", false); |
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.
Boolean parameter in public method should be avoided. Consider creating separate methods with meaningful names instead of using a boolean flag.
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 function was produced for the previous SLR functionality, so we will avoid changing it.
@@ -160,6 +160,7 @@ dependencies { | |||
// Include all jar-files in the 'lib' folder as dependencies | |||
implementation fileTree(dir: 'lib', includes: ['*.jar']) | |||
|
|||
|
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.
Does an AI bot create these empty lines?
I would recommend to review a commit using git gui!
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.
My accident actually! A member of my team had accidentally added a few dependencies and removed some when trying to add the git functionality to the main menu (He wanted to add an icon next to "Git"). I was removing these dependencies manually and left a line. Will fix that and review the changes properly next time, thank you.
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.
Quick comment; I am in the road currently
- Localisation tests were failing. Added keys yo JabRef_en.properties. - Bot mentioned issues with logger, these have been resolved.
…t fix. - Removed CheckForVersionControlActionTest.java and working on a replacement. - fixed properties file issue
…into Happy-Days-Git-Integration-WP3
public void postSaveDatabaseAction(GitPreferences preferences) { | ||
if (this.isGitRepository() && | ||
preferences.getAutoPushMode() == AutoPushMode.ON_SAVE && | ||
preferences.getAutoPushEnabled()) { |
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 should validate the preferences parameter for null before accessing its methods. Current implementation may throw NullPointerException if preferences is 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.
I am going to delete the enum in its entirety as the combo-box is no longer necessary for the scope of this PR. Will make the adjustments as necessary.
} | ||
|
||
@Override | ||
public void execute() { |
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 lacks JavaDoc despite being a public method that performs complex Git operations. Complex public methods should have comprehensive documentation.
.setRef(commit.toString()) | ||
.call(); | ||
} catch (GitAPIException e) { | ||
LOGGER.error("Failed to rever to commit"); |
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.
Typo in error message ('rever' instead of 'revert') and the exception 'e' is not included in the log message, losing valuable debugging information
.setRebase(true) | ||
.call(); | ||
} catch (GitAPIException e) { | ||
LOGGER.error("Failed to pull and rebase"); |
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.
Exception 'e' is not included in the log message, which loses stack trace and error details needed for debugging
try { | ||
this.pullAndRebaseOnCurrentBranch(); | ||
dialogService.notify(Localization.lang("Successfully pulled")); | ||
} catch (IOException 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.
Try block covers multiple statements including notification, violating the principle of minimal try block coverage
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. |
I think, we "discussed" this for 10 secons in one of our meetings. This was too fast. If possible Move it below "General" with "Saving" as heading. (Hint to me and you for a next project: More time for discussions / issue refinement. Write and check minutes. Wirte minitues in a shared manner - e.g., Etherpad (https://pad.riseup.net/) or Microsoft Word online on OneDrive) |
Update. Seems to be hard. Just add a new heading below "Saving". - When it comes to integrate WP4, there surely will be a new tab "Git" or "Saving". Due to time constraints, I think, this integration is out of scope of your project. |
This PR addresses Working Package 3 for #12350
We have decided to instead execute on-save functionality as a single line method call in org/jabref/gui/exporter/SaveDatabaseAction.java
We have currently added git preferences under “Saving” in “General”. Is this okay? And if not should we proceed to making a new segment for it in preferences?


Small architecture concern: We opted to pass preferences information into GitHandler through method updateCredentials but are unsure if this is good practice.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)