@echo off setlocal EnableDelayedExpansion set "_errorlevel=0" set "VCS_GIT=git@exe@" set "VCS_HG=" set "VCS_SVN=" set "VCS_TAR=tar@exe@" goto :select_operation :vcs_type if not defined VCS_GIT goto :vcs_type_not_git if not exist "%1\.git" goto :vcs_type_not_git set "_type=git" exit /b 0 :vcs_type_not_git if not defined VCS_HG goto :vcs_type_not_hg if not exist "%1\.hg" goto :vcs_type_not_hg set "_type=hg" exit /b 0 :vcs_type_not_hg if not defined VCS_SVN goto :vcs_type_not_svn if not exist "%1\.svn" goto :vcs_type_not_svn set "_type=svn" exit /b 0 :vcs_type_not_svn set "_type=unknown" exit /b 0 :vcs_clone if not defined VCS_GIT goto :vcs_clone_not_git "%VCS_GIT%" clone "%1" "%2" if not ERRORLEVEL 1 goto :vcs_clone_success :vcs_clone_not_git if not defined VCS_HG goto :vcs_clone_not_hg "%VCS_HG%" clone "%1" "%2" if not ERRORLEVEL 1 goto :vcs_clone_success :vcs_clone_not_hg if not defined VCS_SVN goto :vcs_clone_not_svn "%VCS_SVN%" checkout "%1" "%2" if not ERRORLEVEL 1 goto :vcs_clone_success :vcs_clone_not_svn echo.gambvcs could not clone %1 exit /b 1 :vcs_clone_success exit /b 0 :vcs_update call :vcs_type "%1" if not "%_type%" == "git" goto :vcs_update_not_git cd "%1" && "%VCS_GIT%" pull if ERRORLEVEL 1 goto :vcs_update_failure exit /b 0 :vcs_update_not_git if not "%_type%" == "hg" goto :vcs_update_not_hg "%VCS_HG%" -R "%1" -u if ERRORLEVEL 1 goto :vcs_update_failure exit /b 0 :vcs_update_not_hg if not "%_type%" == "svn" goto :vcs_update_not_svn cd "%1" && "%VCS_SVN%" update if ERRORLEVEL 1 goto :vcs_update_failure exit /b 0 :vcs_update_not_svn :vcs_update_failure exit /b 1 :vcs_copy call :vcs_type "%1" if not "%_type%" == "git" goto :vcs_copy_not_git if "%2" == "" ( cd "%1" && "%VCS_GIT%" archive HEAD | "%VCS_TAR%" xf - -C "%3" ) else ( cd "%1" && "%VCS_GIT%" archive "tags/%2" | "%VCS_TAR%" xf - -C "%3" ) if ERRORLEVEL 1 goto :vcs_copy_failure exit /b 0 :vcs_copy_not_git if not "%_type%" == "hg" goto :vcs_copy_not_hg if "%2" == "" ( "%VCS_HG%" archive -R "%1" "%3" ) else ( "%VCS_HG%" archive -R "%1" -r "%2" "%3" ) if ERRORLEVEL 1 goto :vcs_copy_failure exit /b 0 :vcs_copy_not_hg if not "%_type%" == "svn" goto :vcs_copy_not_svn if "%2" == "" ( xcopy@exe@ "%1\trunk" "%3" /s ) else ( xcopy@exe@ "%1\tags\%2" "%3" /s ) if ERRORLEVEL 1 goto :vcs_copy_failure exit /b 0 :vcs_copy_not_svn :vcs_copy_failure exit /b 1 :select_operation if "%1" == "type" goto type if not "%1" == ""type"" goto not_type :type call :vcs_type "%VCS_TYPE_DIR_PARAM%" echo %_type% set "_errorlevel=%ERRORLEVEL%" goto end :not_type if "%1" == "clone" goto clone if not "%1" == ""clone"" goto not_clone :clone call :vcs_clone "%VCS_CLONE_REPO_PARAM%" "%VCS_CLONE_DIR_PARAM%" set "_errorlevel=%ERRORLEVEL%" goto end :not_clone if "%1" == "update" goto update if not "%1" == ""update"" goto not_update :update call :vcs_update "%VCS_UPDATE_REPO_PARAM%" set "_errorlevel=%ERRORLEVEL%" goto end :not_update if "%1" == "copy" goto copy if not "%1" == ""copy"" goto not_copy :copy call :vcs_copy "%VCS_COPY_REPO_PARAM%" "%VCS_COPY_TAG_PARAM%" "%VCS_COPY_DIR_PARAM%" set "_errorlevel=%ERRORLEVEL%" goto end :not_copy echo.gambvcs.bat unknown operation "%1" exit /b 1 :end exit /b %_errorlevel%