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

こ雲淡風輕ζ 提交于 2019-12-08 08:45:22

问题


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>

回答1:


The equivalent for:

  • cleartool update would be git pull (provided the Git repository is already cloned)

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.

  • cleartool co -nc ...: no need, a Git repository is in read/write locally. There is no "cleartool checkout" needed.

  • cleartool ci: you would need to add, commit and push

That is:

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

See more on the difference between ClearCase and Git in

  • "What are the basic ClearCase concepts every developer should know?" (March 2009)
  • "ClearCase advantages/disadvantages"


来源:https://stackoverflow.com/questions/56749901/i-have-ant-script-which-works-for-clearcase-can-any-one-help-me-to-convert-it-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!