我的 build.xml 文件中有以下几行:
<target name="svn.load.properties" description="Load svn revision properties">
<loadfile property="svn.info.author" srcFile=".svn/entries" failonerror="true">
<filterchain>
<headfilter lines="12"/>
<tailfilter lines="1"/>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="(.*)([\r\n].*)*" flags="s" replace="\1"/>
</tokenfilter>
</filterchain>
</loadfile>
</target>
但"svn.info.author"
属性的值最终为“12”(因此 .svn / entries 文件只包含一个值 - “12”)。同时,正确显示svn提交日志中修订版作者的名称(从我的svn凭据登录)。我可以更改此文件( .svn / entries )以检索修订版作者的名称,如果是,那么如何(使用哪些规则),或者如何以其他方式检索修订版作者的名称?
据我了解,问题出在我的 .svn / entries 文件中。那么为什么这个文件不包含除“12”以外的任何内容?
答案 0 :(得分:0)
您应该使用官方的svn ant任务here。
下载最后release。
解压缩。
在doc文件夹中,打开文件&#34; svn.html&#34;在浏览器中。
查看&#34; info&#34;任务。
它说:该任务设置以下属性(相应地应用前缀):author。
答案 1 :(得分:0)
您可以使用诸如subWCRev之类的工具来更改项目中的.properties文件,然后读取该文件。就像(https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-subwcrev.html)
假设您有一个带有build_info_template.properties的项目 这些条目:
build.major.number=01
build.minor.number=00
build.revision.number=00
build.svn.revision.number=$WCREV$
build.svn.revision.date=$WCNOWUTC$
在您的Ant脚本上之后,您必须运行SubWCRev:
<target name="update_properties">
<!-- update properties file with subWCRev(Tortoise)-->
<exec executable="cmd">
<arg value="/c" />
<arg value="SubWCRev" />
<!--Project folder-->
<arg value="C:\Desenv\workspaceServer\project" />
<!--Template file-->
<arg value="C:\Desenv\workspaceServer\project\Ant\build_info_template.properties" />
<!--Target file-->
<arg value="C:\Desenv\workspaceServer\project\Ant\build_info.properties" />
<!--Suppress outline-->
<arg value="-q" />
</exec>
</target>
运行目标update_properties后,您将读取生成的属性文件(不是模板),并显示以下内容:
<property file="build_info.properties" />
<property name="svn.build.number" value="${build.svn.revision.number}" />
瞧瞧,只需使用您的svn.build.number变量。