我已使用以下 ant 详细信息来检索签出分支的最新提交 ID,使用此方法我应该注意哪些注意事项?
是否存在我无法检索预期值的极端情况?
<scriptdef name="substring" language="javascript">
<attribute name="text" />
<attribute name="start" />
<attribute name="end" />
<attribute name="property" />
<![CDATA[
var text = attributes.get("text");
var start = attributes.get("start");
var end = attributes.get("end") || (text.length() - 1);
project.setProperty(attributes.get("property"), text.substring(start, end));
]]>
</scriptdef>
<loadfile property="head.branch" srcfile="${basedir}/.git/HEAD" />
<substring text="${head.branch}" start="5" property="branch" />
<loadfile property="head.commitId" srcfile="${basedir}/.git/${branch}"/>