Add commit + push funcionality to git - #16440
Conversation
|
Hey @Campalans03! 👋 Thank you for contributing to JabRef! We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request. After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs. You can read about the whole pull request process in our contribution guide. Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures. |
PR Summary by QodoAdd one-click Commit + Push action to Git Commit dialog
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1.
|
wanling0000
left a comment
There was a problem hiding this comment.
LGTM. Tested it locally and works fine. When I broke the remote on purpose, it showed "Git Push Failed" and the commit was still saved. That partial-failure handling is nice
| private record ResolvedRepository(BibDatabaseContext database, Path bibFilePath, GitHandler gitHandler) { | ||
| } | ||
|
|
||
| /// What a finished dialog action actually achieved, so the user can be told the truth about it. |
There was a problem hiding this comment.
nitpick: the enum values are already self-explanatory here
InAnYan
left a comment
There was a problem hiding this comment.
Ok, that's nice!
Control-flow using exceptions is not really in the JabRef style, but I think that it is good to have a distinction between errors
…mpalans03/jabref into feature/16339-commit-and-push
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
| try { | ||
| PushResult result = GitSyncService.create(guiPreferences.getImportFormatPreferences(), gitHandlerRegistry) | ||
| .push(repository.database(), repository.bibFilePath()); | ||
| return result.noop() ? CommitOutcome.COMMITTED_WITHOUT_PUSH : CommitOutcome.COMMITTED_AND_PUSHED; |
There was a problem hiding this comment.
Can noop() happen here? ithink it is only true for UP_TO_DATE, but commitOn() above throws unless a commit was created, so the branch should always be AHEAD,
so if itis unreachable, drop COMMITTED_WITHOUT_PUSH, and if not, the message contradicts the commit that just happened
| .onFailure(ex -> | ||
| dialogService.showErrorDialogAndWait( | ||
| Localization.lang("Git Commit Failed"), | ||
| ex instanceof PushFailedException | ||
| ? Localization.lang("Git Push Failed") | ||
| : Localization.lang("Git Commit Failed"), |
There was a problem hiding this comment.
push failure shows "Git Push Failed" + the cause, but nothing says the commit was made so it reads as if the whole thing failed, so if the user retries, they then get "Nothing to commit.", which is confusing, right?
|
@Campalans03, any updates? |
Yeah, sorry for not responding! I totally forgot. I’m actually not home until the 19th, so unfortunately I can’t change it right now. I’ll change it as soon as I get home. |
No worries, i hope all is well with you |
|
Thank you @ThinkerDesigns for your interest in JabRef and trying to craft a summary of the previous discussion. However, I think you missed the point of last week comments: @LoayTarek5 made comments the original contributor agreed to address. Also there are currently merge conflicts with main branch, so I cannot consent to your verdict for approval in the current state. Thus is I think your comment is premature. I also have the suspicion that your comment was automatically generated with a LLM. If this is true, please avoid posting in our repository again, as we already have Qodo as an AI bot integrated in our workflows and a less qualified @Campalans03 : Thank you for your work so far. Looking forward to have this finished and merged. |

Summary
Adds a button in
GitCommitDialog.fxmlthat allows committing and pushing in a single action. RefactoredGitCommitDialogViewModelwith newcommitAndPushmethods that reuse the existing commit and push implementations, and added custom error messages for partial failures (e.g. commit succeeds but push fails) and total failures.Steps to test
Related issues and pull requests
Closes #16339
AI usage
Claude Sonnet 5 — used to search for already-implemented functions in the codebase (existing commit/push logic) to avoid duplication. The code was manually written, reviewed and tested.
AI CHECKLIST.md walkthrough
1. Code self-review
Nullability and control flow
== null/!= nullchecks —commitOn()now usesStringUtil.isBlank(message).Objects.requireNonNull(...)— none introduced.@NullMarked.ResolvedRepository,CommitOutcome, andPushFailedExceptionare new types introduced in this PR and are still not annotated.Optionalconsumed withifPresent/ifPresentOrElse/map/orElseThrow. Not applicable: theisEmpty()+.get()block inresolveRepository()is pre-existing code, unchanged in this diff (moved verbatim from the originaldoCommit()).StringUtil.isBlank(...)used instead ofs == null || s.isBlank().Exceptions
catch (Exception e)— only specific exceptions caught (JabRefException | GitAPIException | IOException).throw new RuntimeException(...)/IllegalStateException(...).LOGGERcalls added.Style and idioms
BibEntryobjects built with withers — not applicable, noBibEntrycreated.List.of(),Path.of(), text blocks, etc.) — not applicable, none introduced.Pattern— not applicable, no regex used.BackgroundTask—BackgroundTask.wrap(...)used for both commit and commit+push.///) uses Markdown syntax, not JavaDoc inline tags — used correctly onCommitOutcomeandPushFailedException.User-facing text
Localization.lang/%prefix in FXML) — new strings "Commit and push" and "Committed and pushed successfully" added toJabRef_en.properties.!; labels don't end with:— new strings follow sentence case.Security
Tests
org.jabref.model/org.jabref.logichave tests — not applicable: all new code lives inorg.jabref.gui.git(ViewModel/View layer). The reused push logic (GitSyncService) is pre-existing and already covered byGitSyncServiceTest.GitCommitDialogViewModelTestwas added for the newcommitAndPushflow.2. Verification commands
./gradlew :jablib:check/./gradlew check./gradlew checkstyleMain checkstyleTest checkstyleJmh./gradlew modernizer./gradlew --no-configuration-cache :rewriteDryRun./gradlew javadocnpx markdownlint-cli2 "docs/**/*.md" "*.md"— not applicable, no Markdown changed exceptCHANGELOG.md(not run in this review pass — must be run locally before opening the PR)
3. Documentation
CHANGELOG.mdentry added, end-user wording, links issue Add Commit and Push Feature #16339.docs/requirements/<area>.md— nogit.mdexists underdocs/requirements; this is a new user-facing feature, consider adding one.docs/— not applicable, no architecture change (wires existingGitSyncService).4. Pull request
.github/PULL_REQUEST_TEMPLATE.md, every section filled.gh pr create --body-file <file>.CHANGELOG.mdTODOplaceholder replaced — not applicable, issue number was already known.Images
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)