gitantclearcaseclearcase-automation

I have ant script which works for clearcase. Can any one help me to convert it to GIT


I am migrating one application from clear case to GIT. A build script is written to increment build number and it is written with respect to clear case. And now I have to make it work for GIT. Anyone kindly help me to modify below code to make it work for GIT. I have changed the executable path to GIT.exe. So I just help to convert clear case commands to GIT.

<target name="decBuildNo">
    <trycatch property="exception">
        <try>
            <exec dir="${basedir}\calcBuild" executable="${cleartool}" failonerror="true">
                <arg value="update"/>
                <arg value="setenvs.bat"/>
            </exec>
            <!-- update the build number in setenvs.bat and check in-->
            <exec dir="${basedir}\calcBuild" executable="${cleartool}" failonerror="true">
                <arg value="co"/>
                <arg value="-c"/>
                <arg value="&quot;bump version number&quot;"/>
                <arg value="setenvs.bat"/>
            </exec>
            <decrbuild buildNumberKey="CALCMGR_BUILD_NO" fileName="${basedir}\calcBuild\setenvs.bat"/>
            <exec dir="${basedir}\calcBuild" executable="${cleartool}" failonerror="true">
                <arg value="ci"/>
                <arg value="-c"/>
                <arg value="&quot;bump version number&quot;"/>
                <arg value="setenvs.bat"/>
            </exec>
        </try>
        <catch>
            <echo>Increment build number failed: ${exception}</echo>
            <antcall target="buildfailed"/>
            <fail>${exception}</fail>
        </catch>
    </trycatch>
</target>

Solution

  • The equivalent for:

    If you really want to update only one file setenvs.bat, you would need:

    git fetch
    git checkout HEAD -- setenvs.bat
    

    git checkout is not cleartool checkout (co): it updates the file content, it does not "creates a writable copy".
    See "What is the difference between a reserved checkout and an unreserved checkout?", where I do compare it with Git.

    That is:

    git add setenvs.bat
    git commit -m "bump version number"
    git push
    

    See more on the difference between ClearCase and Git in