Skip to content

[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

Draft
wants to merge 97 commits into
base: main
Choose a base branch
from

Conversation

11raphael
Copy link
Contributor

This PR addresses Working Package 3 for #12350

We shall go through org.jabref.model.database.BibDatabaseContext to execute on-save functionality.

We have decided to instead execute on-save functionality as a single line method call in org/jabref/gui/exporter/SaveDatabaseAction.java

“With regards to implementing preferences- we shall proceed with adding preferences to the current 'Saving' under the "General" tab as suggested. If the segment gets cluttered we shall opt for a new "Saving" tab.”

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?
image
image

Small architecture concern: We opted to pass preferences information into GitHandler through method updateCredentials but are unsure if this is good practice.

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [x ] Tests created for changes (if applicable)
  • [x ] Manually tested changed features in running JabRef (always required)
  • [ x] Screenshots added in PR description (if change is visible to the user)
  • [ x] Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • [ x] Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

RapidShotzz and others added 30 commits February 26, 2025 13:09
Update GitHandler constructor to optionally not create a repository if
none exists
…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
…d-pull' into library-under-version-control-and-pull

# Conflicts:
#	src/main/java/org/jabref/logic/preferences/CliPreferences.java
}

@Override
public void execute() {
Copy link

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.

@koppor
Copy link
Member

koppor commented Mar 19, 2025

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?

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.

grafik

(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)

@koppor
Copy link
Member

koppor commented Mar 19, 2025

If possible Move it below "General" with "Saving" as heading.

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.

@SihasA
Copy link
Contributor

SihasA commented Mar 20, 2025

Screenshot 2025-03-20 at 1 54 08 PM

Just add a new heading below "Saving"

Thank you for the clarification- to ensure I understood correctly, is this what you meant @koppor?

@koppor
Copy link
Member

koppor commented Mar 20, 2025

Just add a new heading below "Saving"
Thank you for the clarification- to ensure I understood correctly, is this what you meant @koppor?

Yes 😅

arp-23 and others added 4 commits March 20, 2025 14:53
Refactor postSaveDatabaseAction to properly handle exceptions
Add dialog messages to push and pull method
@koppor koppor changed the base branch from gitintegration to main March 21, 2025 15:04
@koppor
Copy link
Member

koppor commented Mar 21, 2025

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.

@JabRef JabRef deleted a comment from github-actions bot Mar 24, 2025
@koppor
Copy link
Member

koppor commented Mar 24, 2025

I merged main with the hope that trag-bot will look into this.

Copy link
Member

@koppor koppor left a 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

Comment on lines +241 to +244
new GitClientHandler(targetPath.getParent(),
dialogService,
preferences.getGitPreferences())
.postSaveDatabaseAction();
Copy link
Member

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?

Comment on lines +30 to +32
this.gitClientHandler = new GitClientHandler(path.get(),
dialogService,
preferences.getGitPreferences());
Copy link
Member

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:"/>
Copy link
Member

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.
*/

Copy link
Member

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;
}
/**
Copy link
Member

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

Comment on lines +1838 to +1839
String gitHubUsername = getString("gitHubUsername", "");
String gitHubPasskey = getString("gitHubPasskey", "");
Copy link
Member

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();
Copy link
Member

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 {
Copy link
Member

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

Comment on lines +87 to +89
} catch (IOException e) {
throw new AssertionError("Failed to set up test directory", e);
}
Copy link
Member

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);
Copy link
Member

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(....).

@koppor koppor mentioned this pull request Mar 25, 2025
4 tasks
@koppor
Copy link
Member

koppor commented Mar 25, 2025

I merged main with the hope that our bots will comment with the most important things to adress - it are JUnit tests failing, isn't it?

Copy link

trag-bot bot commented Mar 25, 2025

@trag-bot didn't find any issues in the code! ✅✨

@jabref-machine
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants