Build ant
This commit is contained in:
parent
1a04ecd81a
commit
c643adadf4
110
build.xml
110
build.xml
@ -86,70 +86,74 @@
|
||||
<fail message="Git is required." unless="git.present"/>
|
||||
|
||||
<echo message="🔁 Attempting history recovery..."/>
|
||||
<!-- Получение всех ревизий в порядке от новой к старой -->
|
||||
|
||||
<!-- Получаем список ревизий -->
|
||||
<exec executable="git" output="revs.txt" failonerror="true">
|
||||
<arg value="rev-list"/>
|
||||
<arg value="HEAD"/>
|
||||
</exec>
|
||||
|
||||
<!-- Загружаем список ревизий -->
|
||||
<loadfile property="revs" srcFile="revs.txt"/>
|
||||
<script language="javascript"><![CDATA[
|
||||
var revs = project.getProperty("revs").split("\n");
|
||||
var File = java.io.File;
|
||||
var BufferedWriter = java.io.BufferedWriter;
|
||||
var FileWriter = java.io.FileWriter;
|
||||
<!-- Читаем файл построчно -->
|
||||
<loadfile property="rev.lines" srcFile="revs.txt"/>
|
||||
|
||||
var successRev = null;
|
||||
var failedRev = null;
|
||||
<propertyregex property="rev.count" input="${rev.lines}" regexp="(\n|$)" replace="x" casesensitive="false"/>
|
||||
<echo message="📦 Starting rollback through revisions..."/>
|
||||
|
||||
for (var i = 0; i < revs.length; i++) {
|
||||
var rev = revs[i].trim();
|
||||
if (!rev) continue;
|
||||
<property name="last.good" value=""/>
|
||||
<property name="next.bad" value=""/>
|
||||
|
||||
project.log("🔄 Checking out: " + rev);
|
||||
var checkout = project.createTask("exec");
|
||||
checkout.setExecutable("git");
|
||||
checkout.setFailonerror(true);
|
||||
checkout.createArg().setValue("checkout");
|
||||
checkout.createArg().setValue(rev);
|
||||
try {
|
||||
checkout.execute();
|
||||
} catch (e) {
|
||||
project.log("❌ Failed to checkout " + rev);
|
||||
continue;
|
||||
}
|
||||
<foreach list="${rev.lines}" param="rev" target="try-compile">
|
||||
<sequential>
|
||||
<echo message="⏪ Trying revision: @{rev}"/>
|
||||
</sequential>
|
||||
</foreach>
|
||||
|
||||
try {
|
||||
project.executeTarget("clean");
|
||||
project.executeTarget("compile");
|
||||
successRev = rev;
|
||||
if (i > 0) failedRev = revs[i - 1];
|
||||
project.log("✅ Successfully compiled: " + rev);
|
||||
break;
|
||||
} catch (e) {
|
||||
project.log("❌ Failed to compile: " + rev);
|
||||
}
|
||||
}
|
||||
<condition property="found.good">
|
||||
<isset property="last.good"/>
|
||||
</condition>
|
||||
|
||||
if (successRev == null) {
|
||||
project.log("🛑 No working revision found.");
|
||||
} else if (failedRev != null) {
|
||||
project.log("📄 Generating diff between " + failedRev + " and " + successRev);
|
||||
<fail message="🛑 No working revision found!" unless="found.good"/>
|
||||
|
||||
var diffTask = project.createTask("exec");
|
||||
diffTask.setExecutable("git");
|
||||
diffTask.setFailonerror(false);
|
||||
diffTask.createArg().setValue("diff");
|
||||
diffTask.createArg().setValue(failedRev);
|
||||
diffTask.createArg().setValue(successRev);
|
||||
diffTask.setOutput(new File("diff.patch"));
|
||||
diffTask.execute();
|
||||
<echo message="✅ Working revision found: ${last.good}"/>
|
||||
<echo message="📄 Diffing against: ${next.bad}"/>
|
||||
|
||||
project.log("📝 Diff written to diff.patch");
|
||||
} else {
|
||||
project.log("ℹ️ No previous failed revision to diff from.");
|
||||
}
|
||||
]]></script>
|
||||
<exec executable="git">
|
||||
<arg value="diff"/>
|
||||
<arg value="${next.bad}"/>
|
||||
<arg value="${last.good}"/>
|
||||
<redirector output="diff.patch"/>
|
||||
</exec>
|
||||
|
||||
<echo message="📝 Diff saved to diff.patch"/>
|
||||
</target>
|
||||
|
||||
<target name="try-compile" unless="found.good">
|
||||
<property name="current.rev" value="@{rev}"/>
|
||||
<exec executable="git" failonerror="true">
|
||||
<arg value="checkout"/>
|
||||
<arg value="${current.rev}"/>
|
||||
</exec>
|
||||
<trycatch property="compile.success">
|
||||
<try>
|
||||
<antcall target="clean"/>
|
||||
<antcall target="compile"/>
|
||||
</try>
|
||||
<catch>
|
||||
<echo message="❌ Failed to compile at ${current.rev}"/>
|
||||
</catch>
|
||||
</trycatch>
|
||||
<condition property="compile.success">
|
||||
<available file="${build.dir}"/>
|
||||
</condition>
|
||||
<if>
|
||||
<isset property="compile.success"/>
|
||||
<then>
|
||||
<property name="last.good" value="${current.rev}"/>
|
||||
<property name="found.good" value="true"/>
|
||||
</then>
|
||||
<else>
|
||||
<property name="next.bad" value="${current.rev}"/>
|
||||
</else>
|
||||
</if>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
BIN
lib/ant-contrib-1.0b3.jar
Normal file
BIN
lib/ant-contrib-1.0b3.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user