-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[WIP] Happy days git integration wp3 #12773
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
base: main
Are you sure you want to change the base?
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
} | ||
|
||
@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.
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. |
![]()
Thank you for the clarification- to ensure I understood correctly, is this what you meant @koppor? |
Yes 😅 |
…into Happy-Days-Git-Integration-WP3
Refactor postSaveDatabaseAction to properly handle exceptions Add dialog messages to push and pull method
I changed branch from gitintegration to main since this seems to be unrelated to the other features (yet). You fan do integration on one of your forks. |
I merged |
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.
On a good way IMHO
new GitClientHandler(targetPath.getParent(), | ||
dialogService, | ||
preferences.getGitPreferences()) | ||
.postSaveDatabaseAction(); |
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.
Lifecycle is strange - the GitClientHandler
should be bound to the BibdatabaseContext
(or libraryTab
), shouldn't it?
There is also an instance in src/main/java/org/jabref/gui/importer/actions/CheckForVersionControlAction.java
. I think, the instance should be shared?
this.gitClientHandler = new GitClientHandler(path.get(), | ||
dialogService, | ||
preferences.getGitPreferences()); |
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 is a side effect of a simple boolean
check. Can't it be done differently?
Maybe bind the GitClienthandler to the BibDatbaseContext?
|
||
<Label styleClass="sectionHeader" text="%Git"/> | ||
<HBox spacing="10"> | ||
<Label text="Git Username:"/> |
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.
Please see two lines above how localiaztion works.
Moreover, no : at the end
* If the directory is a Git repository, performs a pull operation on the current branch. | ||
* Will log any errors that occur during the pull operation. | ||
*/ | ||
|
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.
Please remove empty line - JavaDoc is connected to the method directly.
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
} | ||
/** |
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.
Please add a space above
String gitHubUsername = getString("gitHubUsername", ""); | ||
String gitHubPasskey = getString("gitHubPasskey", ""); |
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.
Please read on at org.jabref.logic.preferences.JabRefCliPreferences#getProxyPreferences how JabRef stores passwords.
--> We use com.github.javakeyring.Keyring - and DO NOT STORE PASSWORDS IN PLAIN TEXT
|
||
@Test | ||
void constructorInitialisesValues() { | ||
assertThat(gitPreferences.getAutoPushEnabled()).isTrue(); |
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.
JabRef more uses plain JUnit5.
Please use assertTrue
instead of (........isTrue())
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.when; | ||
|
||
class GitClientHandlerTest { |
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 is currently just a skeletton of a test.
Either test with a real git repository (which could be created locally durent the setup phase of this test) - or just remove this test.
--> Work Package 4 could build on this infrastructure
} catch (IOException e) { | ||
throw new AssertionError("Failed to set up test directory", 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.
Do not catch exceptions - jsut add throws clause
void performAction_WhenGitPullSucceeds_ShouldNotThrowException() { | ||
when(databaseContext.getDatabasePath()).thenReturn(Optional.of(gitRepo.resolve("test.bib"))); | ||
|
||
action.isActionNecessary(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.
THis code reads strange - it is because of the side effect
At least, you should do assertTrue(....)
.
I merged |
@trag-bot didn't find any issues in the code! ✅✨ |
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. |
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)