Skip to content

[#442] Replace CommandRunner with JGit for GitBranch#1454

Open
dcshzj wants to merge 1 commit into
reposense:masterfrom
dcshzj:442-deprecate-commandrunner
Open

[#442] Replace CommandRunner with JGit for GitBranch#1454
dcshzj wants to merge 1 commit into
reposense:masterfrom
dcshzj:442-deprecate-commandrunner

Conversation

@dcshzj

@dcshzj dcshzj commented Feb 13, 2021

Copy link
Copy Markdown
Member

Part of #442.

CommandRunner should be deprecated and replaced by JGit as it
requires Git to be installed and has poor exception handling.
JGit is able to handle Git operations natively, which makes it
more robust to use.

Let's replace usages of CommandRunner with their equivalents in
JGit, starting with GitBranch.

This PR is a proof-of-concept of what JGit can potentially do, instead of relying on CommandRunner.

CommandRunner should be deprecated and replaced by JGit as it
requires Git to be installed and has poor exception handling.
JGit is able to handle Git operations natively, which makes it
more robust to use.

Let's replace usages of CommandRunner with their equivalents in
JGit, starting with GitBranch.
currentRepoDefaultBranch = GitBranch.getCurrentBranch(bareRepoPath);
} catch (GitBranchException gbe) {
// GitBranch will throw this exception when repository is empty
logger.log(Level.WARNING, String.format(MESSAGE_ERROR_GETTING_BRANCH,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this given you have added code for this already? Or did you forget to remove it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't remove this exception handling as I think that there might be some other errors that may occur. For instance, GitBranchException is thrown because an IOException occurred, which probably happened if the directory given is not a Git repository (which shouldn't happen).

@damithc

damithc commented Feb 15, 2021

Copy link
Copy Markdown
Collaborator

Good to do a light exploration of this direction at first before going hard at it. For example, we can try to get it working first before deciding whether to merge (hence, no need for a detailed review of the PR first)
I'm particularly worried about not being able to use the all/latest features/improvements of Git and not particularly worried about having to install Git first. It's not unreasonable to expect users to have Git if they want to run RepoSense locally.
If we decide not to go forward, we should still document pros and cons found.

@dcshzj

dcshzj commented Feb 15, 2021

Copy link
Copy Markdown
Member Author

I have updated my original comment in #442 with a pros and cons list based on the research that I have done on JGit, so that we can make a more informed decision.

@fzdy1914

Copy link
Copy Markdown
Member

As the discussion, I will make it DoNotMerge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants