我有一个生成脚本文件的shell脚本:
git diff --word-diff origin/$ghprbTargetBranch origin/$1 > diff1.txt
现在,我需要从JGIT中读取diff1.txt补丁文件,以获取所有文件更改。 diff1.txt如下所示:
diff --git a/src/objects/Account.object b/src/objects/Account.object
index 0bd43e4..f827031 100644
--- a/src/objects/Account.object
+++ b/src/objects/Account.object
@@ -133,6 +133,14 @@
<fullName>CleanStatus</fullName>
<trackFeedHistory>false</trackFeedHistory>
</fields>
{+<fields>+}
{+ <fullName>MatchAddress__c</fullName>+}
{+ <defaultValue>false</defaultValue>+}
{+ <externalId>false</externalId>+}
{+ <label>MatchAddress</label>+}
{+ <trackFeedHistory>false</trackFeedHistory>+}
{+ <type>Checkbox</type>+}
{+ </fields>+}
<fields>
<fullName>CustomerPriority__c</fullName>
<externalId>false</externalId>
@@ -240,6 +248,17 @@
<type>Number</type>
<unique>false</unique>
</fields>
{+<fields>+}
{+ <fullName>Check1__c</fullName>+}
{+ <externalId>false</externalId>+}
{+ <label>check1</label>+}
{+ <precision>18</precision>+}
{+ <required>false</required>+}
{+ <scale>0</scale>+}
{+ <trackFeedHistory>false</trackFeedHistory>+}
{+ <type>Number</type>+}
{+ <unique>false</unique>+}
{+ </fields>+}
<fields>
<fullName>NumberofLocations__c</fullName>
<externalId>false</externalId>
是否可以从Java读取补丁文件并仅获取要添加的行?
输出
<fields>
<fullName>MatchAddress__c</fullName>
<defaultValue>false</defaultValue>
<externalId>false</externalId>
<label>MatchAddress</label>
<trackFeedHistory>false</trackFeedHistory>
<type>Checkbox</type>
</fields>
and the next field Check1__C
答案 0 :(得分:0)
浏览完JGIT源代码后,我发现他们如何在JGit中应用补丁,这就是JGit读取补丁并应用补丁的方式,我只想读取补丁文件。
public QueryResponse query(SolrQuery parameters){
QueryResponse resp=null;
try {
QueryRequest queryRequest=new QueryRequest(parameters);
queryRequest.setMethod(SolrRequest.METHOD.POST);
NamedList nl=solrClient.request(queryRequest);
resp=new QueryResponse(nl, solrClient);
} catch (Exception e) {
e.printStackTrace();
}
return resp;
}