-
-
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
Draft
11raphael
wants to merge
84
commits into
JabRef:gitintegration
Choose a base branch
from
11raphael:Happy-Days-Git-Integration-WP3
base: gitintegration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+713
−22
Draft
Changes from 83 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
01dec74
added methods to and boolean to see if file is under version control …
eb1b9a8
Add CheckForVersionControlAction
11raphael c761db5
Added unit tests for - CheckForVersionControlAction
Ary006 2c9dad4
Added unit tests for - CheckForVersionControlAction
Ary006 ed6eb4a
added functionality for tagging as versioned and pulling only if pref…
9cbdd76
moved test file and amended shouldAutoPull method to test.org.jabref.…
62defc4
Remove RuntimeException from CheckForVersionControlAction
11raphael bbc6b38
Remove redundant methods from GitHandler
11raphael 69e0f9a
modified the test cases for CheckForVersionControlAction
Ary006 d578bd5
Merge remote-tracking branch 'origin/library-under-version-control-an…
Ary006 cf32088
modified the test cases for CheckForVersionControlAction
Ary006 c670625
modified the test cases for CheckForVersionControlAction
Ary006 9026eb9
modified the test cases for CheckForVersionControlAction
Ary006 40cdd64
modified the test cases for CheckForVersionControlAction
Ary006 8db799c
Remove preference in CheckForVersionControlAction
11raphael af0c3c8
Add git preferences
11raphael 1f2de0a
Add GitPreferences to CliPreferences
11raphael cfd46db
added autoPushEnabled attributes and set methods
6ecf1a8
modified tab view model to handle auto push
a0e2dc7
Add getGitPreferences to JabRefCliPreferences
11raphael c8be361
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael 5127bca
Merge branch 'Happy-Days-Git-Integration-WP3' into library-under-vers…
11raphael 2bf349d
Remove redundant shouldAutoPull from CliPreferences
11raphael bff9857
Added a rudimentary first draft preference selector under Saving in g…
SihasA c197264
Merge remote-tracking branch 'origin/library-under-version-control-an…
11raphael f7c21c4
removed duplicate boolean
980c748
Cleaned up UI - "Auto push" Combo Box no longer is in all Caps
SihasA caf405b
Added "Git" submenu with "Git Pull" and "Git Push" options
Ary006 4ed64cd
constructed get git preferences
45c453e
Merge branch 'library-under-version-control-and-pull' into Happy-Days…
11raphael 3ff8bc3
Add autoPushMode to GitPreferences
11raphael 63d86f1
Add git functionality on database save to GitHandler and SaveDatabase…
11raphael 837311f
Create GitPullAction for git pull menu item
11raphael 53286d4
Fix: Rename GitPullAction and correct GitHandler repository path in c…
11raphael cd6ff23
modified getGitPreferences to account for getAutoPushModeProperty() m…
f2fae4b
Remove redundant parameter from GeneralTabViewModel
11raphael 7b0e930
Clean 'Failed to push' logger message
11raphael c28b84f
removed comments
0e0ddba
Fixed error regarding preferences not saving correctly
SihasA b9ca978
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
SihasA e71d3ad
Fixed error regarding preferences not saving correctly
SihasA 27b0355
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael 6a7e013
Update GitHandler with staging methods and add GitPullAction
11raphael e3885b7
Cleaned up UI Preferences
SihasA 0fd12cc
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael b1458b2
Capitalization
11raphael 98ec8a8
Remove redundant methods from GitHandler
11raphael d9162bc
added tests for git preferences to ensure that auto push functionalit…
e800a28
moved location of gitpreferences test
0c51c0e
Add unit tests for AutoPushMode - covering getDisplayName(), toString…
Ary006 5e0015c
Added Git Username and Passkey fields to preferences
SihasA d5b72bb
Add git credentials logic
11raphael 2586df7
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael bed8cc7
Fix preferences in GitHandler
11raphael 4b71771
demo
11raphael d52d62a
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
SihasA f232305
Fixed merge conflicts and added github passkey and username to prefer…
SihasA 4d91985
Revert "Added Git Username and Passkey fields to preferences"
SihasA 2ea0d72
Fixed Preferences and finished GitFunctionality for basic pull and push
SihasA 2fe1066
Implement auto push on database save
11raphael 8f683f0
Removed Manually option from combobox, will remove combobox in future.
SihasA cdb4c76
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
SihasA 1884dd7
Revert "Implement auto push on database save"
SihasA bde293a
Revert "Revert "Implement auto push on database save""
SihasA 37e0b92
Fix various issues
11raphael f87ab7a
Fixed/ Looked into Bot Comments
SihasA dcc5a06
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael b11f155
Fixed CheckStyleIssues and Bot Issue
SihasA 854af5c
Fixing Bot Comments
SihasA 95197c2
Reverted changes to module-info.java and build.gradle.
SihasA 51e6fd6
Refactor git client functionality into GitClientHandler
11raphael f1fe7f5
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael e3fc84e
Corrected issue - "Method violates fail-fast principle by nesting all…
Ary006 3070087
Corrected issue - "Method violates fail-fast principle by nesting all…
Ary006 4e1c577
Corrected issue - "Method violates fail-fast principle by nesting all…
Ary006 5b278aa
Ran rewriteRun and fixed bot comments
SihasA c305e53
Added localisation and fixed logger issues.
SihasA 9b0bf8f
Fixed one failing test case and removed problematic test + Bot commen…
SihasA 493775b
Add test cases for Git repository detection
arp-23 92df862
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
arp-23 0c0a094
Refactor postSaveDatabaseAction and GitClientHandler
11raphael 6e731cf
Merge remote-tracking branch 'origin/Happy-Days-Git-Integration-WP3' …
11raphael 355ff89
Update postSaveDatabaseAction JavaDoc
11raphael 86edd20
Removed line in build.gradle
SihasA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/org/jabref/gui/importer/actions/CheckForVersionControlAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.jabref.gui.importer.actions; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.logic.git.GitClientHandler; | ||
import org.jabref.logic.importer.ParserResult; | ||
import org.jabref.logic.preferences.CliPreferences; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This action checks whether this BIB file is contained in a Git repository. If so, | ||
* then the file is tagged as "versioned" in BibDatabaseContext and a git pull is | ||
* attempted. | ||
*/ | ||
public class CheckForVersionControlAction implements GUIPostOpenAction { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(CheckForVersionControlAction.class); | ||
private GitClientHandler gitClientHandler; | ||
|
||
@Override | ||
public boolean isActionNecessary(ParserResult parserResult, DialogService dialogService, CliPreferences preferences) { | ||
Optional<Path> path = parserResult.getDatabaseContext().getDatabasePath(); | ||
if (path.isEmpty()) { | ||
return false; | ||
} | ||
this.gitClientHandler = new GitClientHandler(path.get(), | ||
dialogService, | ||
preferences.getGitPreferences()); | ||
return gitClientHandler.isGitRepository(); | ||
} | ||
|
||
@Override | ||
public void performAction(ParserResult parserResult, DialogService dialogService, CliPreferences preferencesService) { | ||
parserResult.getDatabaseContext().setVersioned(true); | ||
|
||
try { | ||
this.gitClientHandler.pullOnCurrentBranch(); | ||
} catch (IOException e) { | ||
LOGGER.error("Failed to pull.", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.jabref.gui.shared; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.logic.git.GitClientHandler; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class GitPullAction extends SimpleCommand { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(GitPullAction.class); | ||
|
||
private final GuiPreferences preferences; | ||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
|
||
public GitPullAction( | ||
GuiPreferences preferences, | ||
DialogService dialogService, | ||
StateManager stateManager) { | ||
this.preferences = preferences; | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
if (stateManager.getActiveDatabase().isEmpty()) { | ||
return; | ||
} | ||
BibDatabaseContext databaseContext = stateManager.getActiveDatabase().get(); | ||
|
||
Optional<Path> path = databaseContext.getDatabasePath(); | ||
if (path.isEmpty()) { | ||
return; | ||
} | ||
|
||
GitClientHandler gitClientHandler = new GitClientHandler(path.get().getParent(), | ||
dialogService, | ||
preferences.getGitPreferences()); | ||
if (gitClientHandler.isGitRepository()) { | ||
try { | ||
gitClientHandler.pullOnCurrentBranch(); | ||
} catch (IOException e) { | ||
LOGGER.error("Failed to Pull", e); | ||
} | ||
} else { | ||
LOGGER.info("Not a git repository at path: {}", path.get()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.jabref.gui.shared; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.logic.git.GitClientHandler; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
||
import org.eclipse.jgit.api.errors.GitAPIException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class GitPushAction extends SimpleCommand { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(GitPushAction.class); | ||
|
||
private final GuiPreferences preferences; | ||
private final DialogService dialogService; | ||
private final StateManager stateManager; | ||
|
||
public GitPushAction( | ||
GuiPreferences preferences, | ||
DialogService dialogService, | ||
StateManager stateManager) { | ||
this.preferences = preferences; | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (stateManager.getActiveDatabase().isEmpty()) { | ||
return; | ||
} | ||
BibDatabaseContext databaseContext = stateManager.getActiveDatabase().get(); | ||
|
||
Optional<Path> path = databaseContext.getDatabasePath(); | ||
if (path.isEmpty()) { | ||
return; | ||
} | ||
|
||
GitClientHandler gitClientHandler = new GitClientHandler(path.get().getParent(), | ||
dialogService, | ||
preferences.getGitPreferences()); | ||
if (gitClientHandler.isGitRepository()) { | ||
try { | ||
gitClientHandler.createCommitOnCurrentBranch("Automatic update via JabRef", false); | ||
gitClientHandler.pushCommitsToRemoteRepository(); | ||
} catch (IOException | GitAPIException e) { | ||
dialogService.showErrorDialogAndWait(e); | ||
} | ||
} else { | ||
LOGGER.info("Not a git repository at path: {}", path); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.