-
-
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
Add git support #10586
Add git support #10586
Conversation
We are migrating our implementation to use java key ring, we were not using it. Now we see the problem. The diff dialog is still under heavy issues (I added the files from the database diff but still difficulty to navigate how to change it to git diffs). It seems more challenging them what we have thought. |
@lbenicio you can replace the whole diff dialog by using JabRefs own feature to compare two libraries (bib files). Remember, the is the "file changed on disk" feature of JabRef. Maybe, you simply write out the file of the remote to the disk and then let JabRef do it's magic. The magic includes a) displaying all diffs and b) guiding the user through accepting, rejecting, and merging changes. |
@koppor We thought, as a v1, we could just create a text dialog with the diff output from the user and let the user decide |
@lbenicio As I understand you, the dialog does not work. What I say: Remove that code, add approx. three lines of code and let JabRef do its magic. For sure, you can train your JavaFX skills with your dialog. Then please add screenshots! |
I don't quite understand how that will work as the class uses bib files, but i will try. |
I tried to pull before save the bib file, but i think file monitor is more slow than save action. Is it possible to check in file monitor if a conflict happened and if user resolved it ? |
The file monitor monitors the file on the disk. Thus, it cannot be slower than the save action.
No. There are other listeners taking care of the work. For the first "MVP", it is enough to save the pulled file and let the user to the work - without going back the path of the save call. The handling of conflicts will be done in another independent thread then. |
Happy new year! 🎉 This PR could take longer to be finished. Do you still have some time? If yes, I would ask you to check the CI output: Checkstyle complains and some other checkers, too. Please check their output. Especially reconfigure IntelliJ to follow JabRef's code style. See https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html for details. You can then use Ctrl+Alt+L to reformat your classes. |
I make the changes, but I don't understand this changelog.md error. |
Not sure, how I should explain. You know software releases? You know that for each version, there is a section in CHANGELOG.md. Thus, for each released version, there is a section. What if updates to the software come? Are older releases changed? No, new releases are made! - What about the CHANGELOG.md sections of older releases? Do new features go into these sections? No, a new section Now, let's check your patch: The patch is in section of version 5.11 of JabRef. It adds a new feature to 5.11. BUT - hey, JabRef 5.11 is already released. See the release date in the heading and the releases at https://github.com/JabRef/jabref/releases. Thus, this patch should NOT go into 5.11, but into the |
All right, and this last one, is it related to what we did? |
I don't understand, where "last one" refers to... |
These Fetcher tests. |
You can ignore the fetcher tests
Marcelo Nascimento ***@***.***> schrieb am Mo., 22. Jan.
2024, 21:25:
… These Fetcher tests.
—
Reply to this email directly, view it on GitHub
<#10586 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACOFZDHVKABZOHT7XPOVNDYP3DNLAVCNFSM6AAAAAA6QCNEUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBUG42DQNBXGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
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 small comments. Still need to try it thoroughly...
try { | ||
return Files.createDirectories(sshDir).toFile(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(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.
JabRef should not crash completely if something goes wrong when using SSH. Better really throw the exception and handle at the caller.
} | ||
} catch (GitAPIException | IOException e) { | ||
LOGGER.error("Failed to force git pull", e); | ||
throw new RuntimeException(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.
JabRef should not be stopped (data loss!!) if some communication goes wrong. Handle differently.
try (Git git = Git.open(this.repositoryPathAsFile)) { | ||
return git.getRepository().getBranch(); | ||
} catch (IOException ex) { | ||
LOGGER.info("Failed get current branch"); | ||
return String.valueOf(Optional.empty()); |
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.
What is this? You can return the empty string (""), but a string of Optional.empty is really strange.
@@ -482,6 +487,7 @@ public class JabRefPreferences implements PreferencesService { | |||
private ColumnPreferences searchDialogColumnPreferences; | |||
private JournalAbbreviationPreferences journalAbbreviationPreferences; | |||
private FieldPreferences fieldPreferences; | |||
private GitPreferences gitPreferences; |
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.
What I meant that multiple providers should be supported. See #10936 for an example for API keys (which are different for different providers). Maybe, this is a follow-up thing.
Note that GitHub supports both HTTP and SSH:
@@ -1614,12 +1626,27 @@ private String getProxyPassword() { | |||
} catch (PasswordAccessException ex) { | |||
LOGGER.warn("JabRef uses proxy password from key store but no password is stored"); | |||
} catch (Exception ex) { | |||
LOGGER.warn("JabRef could not open the key store"); | |||
LOGGER.warn("JabRef could not open the git key store"); |
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.
Wrong change. JabRef also stores other credentials there. Please revert.
Git\ password=Git password | ||
Git\ username=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.
Maybe, one can get rid of this and only use "Username" and "Password", which should already exist here?
LOGGER.info("Git credentials error"); | ||
} catch (GitAPIException e) { | ||
LOGGER.info("Failed to pull"); | ||
throw new RuntimeException(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 crash complete JabRef on an error.
LOGGER.info("No remote repository detected"); | ||
} catch (DetachedHeadException e) { | ||
dialogService.showErrorDialogAndWait(Localization.lang("Git"), Localization.lang("Git detached head")); | ||
LOGGER.info("Git detached head"); |
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.
Why not returning "false" if something goes wrong?
dialogService.showErrorDialogAndWait(Localization.lang("Git"), Localization.lang("Local repository is out of date, please review the library and save again")); | ||
LOGGER.info("Failed to pull"); | ||
return false; | ||
} catch (NoRemoteRepositoryException 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.
I think, all exceptions can be merged into one, because there is no "real" different behavior.
NoRemoteRepositoryException | DetachedHeadException etc..
Please use notifications instead of dialogs. Reason: The flow of the user should not be disturbed while working with git.
repository.incrementOpen(); | ||
return repository; | ||
} | ||
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.
Shouldn't there be an exception?
Unfortunately, my classes started a few days ago and I will not be able to continue this project. If there is someone else who can continue this issue, you can pass it on. |
Ok, yes, we will look into it. Thanks for your work on enhancing JabRef. |
Fixes https://github.com/koppor/jabref/issues/578
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)