JGit API是否具有所有Git命令? [英] Does JGit API have all Git commands
问题描述
我试图将一个shell脚本移植到Java中,该脚本包含几个我在JGit API中可以找到的Git命令。然而,我没有找到远程命令或命令,这是因为它不存在,或者我只是在错误的地方寻找它们。如果它们不存在,是否有另一种方法来使用它们?
没有准备好的对应于<$在JGit中c $ c> git remote 和 am
,但应该可以通过合理的努力来实现它们的一部分。 p>
查询或操作配置文件的那些 git remote
子命令可以通过直接访问存储库配置来模拟 Repository.getConfig()
。
清理过时的远程追踪分支,如 git remote prune
可以,您可以使用 LsRemoteCommand
来获取现有远程分支的列表,并从本地配置中删除不匹配该列表的远程。 / p>
替换 git am
可能会更加努力。有一个 ApplyCommand
来应用来自给定输入流的补丁以及低级 Patch
类来解析diff文件。剩下的就是解析邮箱文件,并从包含的差异和元数据(消息,作者等)中产生提交。
I am trying to port a shell script to Java which contains a few Git commands which I have mostly managed to find in the JGit API. I have not, however, managed to find the remote or am commands, is this because the don't exist or I am just looking in the wrong place for them. If they don't exist is there another way to use them?
There is no ready-to run counterpart for git remote
and am
in JGit, but it should be possible to implement (a subset of) them with reasonable effort.
Those sub-commands of git remote
that query or manipulate the config file can be emulated by directly accessing the repository configuration through Repository.getConfig()
.
To clean stale remote-tracking branches like git remote prune
does, you can use LsRemoteCommand
to obtain a list of existing remote branches and remove remotes from the local configuration that do not match that list.
Replacing git am
might be a little more effort. There is an ApplyCommand
to apply a patch from a given input stream as well as the low-level Patch
class to parse diffs. What would be left is to parse the mailbox files and produce a commit from the contained diffs and meta-data (message, author, etc.).
这篇关于JGit API是否具有所有Git命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!