<commit_before><?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:xalan="http://xml.apache.org/xalan"
                              exclude-result-prefixes="xalan">

<!-- this stylesheet generates an Ant build file (work.build.xml) from the forrestbot
     configuration (forrestbot.conf.xml) -->

<xsl:output indent="yes"/>

<!-- retrieving the list of stages from stages.conf.xml -->
<xsl:variable name="workstages" select="xalan:nodeset(document('../stages.conf.xml'))"/>



<xsl:template match="forrest-config">
  <project basedir="." default="work" name="generated forrestbot build file">
    <xsl:call-template name="listprojects"/>
    <xsl:call-template name="startproject"/>
    <xsl:call-template name="liststagesperproject"/>
   </project>
</xsl:template>



<xsl:template name="listprojects">
<taskdef name="trycatch" classname="net.sf.antcontrib.logic.TryCatchTask">
  <classpath>
    <pathelement location="${{forrest.home}}/forrestbot/lib/ant-contrib-0.1.jar"/>
  </classpath>
</taskdef>


<!--
  per-project invocation of the chain of workstages:
  (for each project element in the input there is a child to the <parallel>
   element in the output)

  <target name="work">
    <parallel>
      <trycatch>
        <try>
          <ant antfile="[this-file]" target="work.[project-name]" .../>
        </try>
        <catch>
          <...>
        </catch>
        <finally>
          <mail .../>
        </finally>
      </trycatch>
    </parallel>
  </target>
-->

   <target name="work">
     <parallel>
       <xsl:for-each select="project">
         <!-- todo: wrap it in try catch to make it send in case of fail as well -->
         <trycatch>
           <try>
             <ant antfile="${{bot.work.build.xml}}" inheritRefs="true"
                  target="{@name}" output="${{bot.build.dir}}/work.{@name}.log"/>
             <property name="mail.completion-status" value="SUCCESS" />
           </try>
           <catch>
             <echo message="Failed to complete workstages for project {@name}" />
             <property name="mail.completion-status" value="FAIL" />
           </catch>
           <xsl:if test="@sendlogto">
       <finally>
         <property name="mail.to" value="{@sendlogto}" />
         <property name="mail.attachments" value="${{bot.build.dir}}/work.{@name}.log" />
         <condition property="mail.send">
           <or>
           <equals arg1="${{mail.completion-status}}" arg2="error" />
                   <equals arg1="{@sendon}" arg2="always" />
         </or>
         </condition>
         <ant antfile="${{bot.templates.build.xml}}" target="template.mail" inheritRefs="true">
           <property name="project.name" value="{@name}" />
         </ant>
             </finally>
           </xsl:if>
         </trycatch>
       </xsl:for-each>
     </parallel>
   </target>
</xsl:template>



<xsl:template name="startproject">

<!--
  list dependency chain of worker task:
  <target name="work.xml-forrest"
          depends="prepare.xml-forrest,
            get-src.xml-forrest,generate.xml-forrest,
            deploy.xml-forrest,cleanup.xml-forrest" />
-->

  <xsl:for-each select="project">
    <xsl:variable name="project.name" select="@name"/>
    <target name="{@name}">
      <xsl:attribute name="depends">
         <xsl:for-each select="$workstages/stages/workstage"><commit_msg>Use correct failure token<commit_after><?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:xalan="http://xml.apache.org/xalan"
                              exclude-result-prefixes="xalan">

<!-- this stylesheet generates an Ant build file (work.build.xml) from the forrestbot
     configuration (forrestbot.conf.xml) -->

<xsl:output indent="yes"/>

<!-- retrieving the list of stages from stages.conf.xml -->
<xsl:variable name="workstages" select="xalan:nodeset(document('../stages.conf.xml'))"/>



<xsl:template match="forrest-config">
  <project basedir="." default="work" name="generated forrestbot build file">
    <xsl:call-template name="listprojects"/>
    <xsl:call-template name="startproject"/>
    <xsl:call-template name="liststagesperproject"/>
   </project>
</xsl:template>



<xsl:template name="listprojects">
<taskdef name="trycatch" classname="net.sf.antcontrib.logic.TryCatchTask">
  <classpath>
    <pathelement location="${{forrest.home}}/forrestbot/lib/ant-contrib-0.1.jar"/>
  </classpath>
</taskdef>


<!--
  per-project invocation of the chain of workstages:
  (for each project element in the input there is a child to the <parallel>
   element in the output)

  <target name="work">
    <parallel>
      <trycatch>
        <try>
          <ant antfile="[this-file]" target="work.[project-name]" .../>
        </try>
        <catch>
          <...>
        </catch>
        <finally>
          <mail .../>
        </finally>
      </trycatch>
    </parallel>
  </target>
-->

   <target name="work">
     <parallel>
       <xsl:for-each select="project">
         <!-- todo: wrap it in try catch to make it send in case of fail as well -->
         <trycatch>
           <try>
             <ant antfile="${{bot.work.build.xml}}" inheritRefs="true"
                  target="{@name}" output="${{bot.build.dir}}/work.{@name}.log"/>
             <property name="mail.completion-status" value="SUCCESS" />
           </try>
           <catch>
             <echo message="Failed to complete workstages for project {@name}" />
             <property name="mail.completion-status" value="FAIL" />
           </catch>
           <xsl:if test="@sendlogto">
       <finally>
         <property name="mail.to" value="{@sendlogto}" />
         <property name="mail.attachments" value="${{bot.build.dir}}/work.{@name}.log" />
         <condition property="mail.send">
           <or>
           <equals arg1="${{mail.completion-status}}" arg2="FAIL" />
                   <equals arg1="{@sendon}" arg2="always" />
         </or>
         </condition>
         <ant antfile="${{bot.templates.build.xml}}" target="template.mail" inheritRefs="true">
           <property name="project.name" value="{@name}" />
         </ant>
             </finally>
           </xsl:if>
         </trycatch>
       </xsl:for-each>
     </parallel>
   </target>
</xsl:template>



<xsl:template name="startproject">

<!--
  list dependency chain of worker task:
  <target name="work.xml-forrest"
          depends="prepare.xml-forrest,
            get-src.xml-forrest,generate.xml-forrest,
            deploy.xml-forrest,cleanup.xml-forrest" />
-->

  <xsl:for-each select="project">
    <xsl:variable name="project.name" select="@name"/>
    <target name="{@name}">
      <xsl:attribute name="depends">
         <xsl:for-each select="$workstages/stages/workstage">
{'fraction_non_alphanumeric': 0.17550486706378032, 'fraction_numerical': 0.004358564579398518, 'mean_word_length': 2.4385614385614387, 'pattern_counts': {'":': 0, '<': 157, '<?xml version=': 2, '>': 157, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 32}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1361001', 'n_tokens_mistral': 2185, 'n_tokens_neox': 2072, 'n_words': 412}