Joh*_*ter 4 java eclipse git jgit
我已经研究过从Java控制Git的可能性.我发现的是:
Runtime.getRuntime().exec("git command")- 让Java用git执行命令我尝试使用Runtime和ProcessBuilder为git编写自己的Java包装器,但是我遇到了进程线程的问题,等待线程完成一些时间.
然后,我研究了其他API解决方案.首先我尝试了JavaGit API,但我根本无法工作.
其次,我测试了JGit API,看起来很棒.但我很快就发现我无法像使用Java包装器那样设置提交日期:
ProcessBuilder pb = new ProcessBuilder("git", "commit", "--date=" + "\"" + customDateString + "\"", "-m \"" + comment + "\"");
Run Code Online (Sandbox Code Playgroud)
我下载了JGit源代码,看看我是否可以实现它,但它读得太多了,我无法在Github上找到任何问题跟踪器,以便JGit提出建议.
有人可以帮我这样做吗?
或者告诉我在哪里可以写信给开发人员提出建议?
C:\> cd C:\Users\VonC\prog\git\
C:\Users\VonC\prog\git> git clone https://github.com/eclipse/jgit
C:\Users\VonC\prog\git> cd jgit
Run Code Online (Sandbox Code Playgroud)
然后搜索tst涉及" authordate" 的测试(' '):
C:\Users\VonC\prog\git\jgit>grep -nRHIi authordate *|grep tst
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java:446: final Date authorDate = new Date(1349621117000L);
Run Code Online (Sandbox Code Playgroud)
这意味着您可以查看org.eclipse.jgit.test.tst.org.eclipse/jgit/api.CommitCommandTest,函数commitAmendWithoutAuthorShouldSetOriginalAuthorAndAuthorTime():
您将看到如何指定作者和作者日期:
final Date authorDate = new Date(1349621117000L);
PersonIdent firstAuthor = new PersonIdent(authorName, authorEmail,
authorDate, TimeZone.getTimeZone("UTC"));
git.commit().setMessage("initial commit").setAuthor(firstAuthor).call();
Run Code Online (Sandbox Code Playgroud)
请注意,正如我在这里提到的,测试类是JGit的文档/插图的良好来源.
| 归档时间: |
|
| 查看次数: |
639 次 |
| 最近记录: |