简体   繁体   English

Windows批处理文件中来自远程存储库的svn head修订-系统找不到指定的文件

[英]svn head revision from a remote repository in windows batch file - the system cannot find the file specified

How do I get a SVN revision number of a remote repository in a windows batch file ? 如何在Windows批处理文件中获取远程存储库的SVN版本号? I want to check for a condition when the user enters blank i have to get HEAD revision. 我想检查条件,当用户输入空白时,我必须获得HEAD修订版。

I'm using the following snippet to get the revision number. 我正在使用以下代码段获取修订号。 Although the for loop returns all the necessary information wrt remote SVN server location including the revision number. 尽管for循环返回有关远程SVN服务器位置的所有必要信息,包括修订号。 Still the batch file throws The system cannot find the file specified and the variable %SVN_VERSION% still remains empty. 批处理文件仍然抛出系统无法找到指定的文件 ,并且变量%SVN_VERSION%仍然为空。

In the below mentioned code, the %SVN_PATH% points to the remote server URL 在下面提到的代码中,%SVN_PATH%指向远程服务器URL

set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"
    if "%SVN_VERSION%" =="" (
    for /f "delims=: tokens=1,2" %%a in ('svn info %SVN_PATH%') do (
              if "%%a"=="Revision:" (
                set /a SVN_VERSION=%%b
            )
        )
    )

Thanks 谢谢

As I mentioned in the comments, you can directly obtain revision with svnversion command . 正如我在评论中提到的那样,您可以使用svnversion command直接获得修订。

@echo off
set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"
if "%SVN_VERSION%"=="" (
    for /f %%a in ('svnversion') do set "SVN_VERSION=%%a"
)
exit /b 0

Edit 编辑

Here it is well explained how to use the command svnversion 在这里很好地解释了如何使用命令svnversion

Edit 编辑

According to your comments and trying to guess in your mind, the following command should work if you know the remote_url 根据您的评论并尝试猜测,如果您知道remote_url,以下命令应该可以使用

@echo off

rem Edit remote_url
set /p "remote_url=Please specify the SVN repo url http://....." || goto:EOF

set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"

if "%SVN_VERSION%"=="" (
    for /f "delims=: tokens=1,2" %%a in ('svn info %remote_url%') do (
        if "%%a"=="Revision" ( set SVN_VERSION=%%b )
    )
)
exit /b 0

Edit 编辑

This should also work since I have seen what should be the input 这也应该起作用,因为我已经看到了输入内容

@echo off

set /p "SVN_VERSION=Please specify the SVN Revision number. For HEAD revision press Enter"

if "%SVN_VERSION%"=="" (
    for /f "tokens=1,2" %%a in ('svn info %SVN_PATH% ^|findstr /ic:"Revision"') do set SVN_VERSION=%%b
)
exit /b 0

Explanation: 说明:
Your mistake was with delims=: since : is not part of the tokens the comparison came wrong. 您的错误是与delims=:在一起的,因为:不是tokens的一部分,所以比较出错。 Also, the default delims is space, so don't need to specify a delims here since the line are splited in two parts. 另外,默认的delims是空格,因此这里不需要指定delims,因为该行分为两部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 批处理文件 - 系统找不到指定的批处理标签 - Windows batch file - The system cannot find the batch label specified 系统找不到指定的路径-批处理文件 - The system cannot find the path specified - Batch file windows批处理文件系统找不到指定的批处理标签-退出 - windows batch file The system cannot find the batch label specified-exit Windows Bat-系统找不到指定的文件 - Windows Bat - The System Cannot Find the File Specified Windows 批处理脚本“系统找不到指定的文件。” 文件名中有感叹号? - Windows batch script "The system cannot find the file specified." with exclamation in filenames? 批处理文件中出现意外的“系统无法找到指定的驱动器。” - Unexpected “The system cannot find the drive specified.” in batch file 无法运行程序“wkhtmltopdf”,系统找不到 windows 中指定的文件 - Cannot run program "wkhtmltopdf", The system cannot find the file specified in windows 使用 SFTP 将文件从 Linux 服务器下载到 Windows 时出现“系统找不到指定的文件” - "The system cannot find the file specified" when using SFTP to download file from Linux Server to Windows Windows批处理文件中的Head -1 - Head -1 in windows batch file Windows Jupyter笔记本上的RPy2:系统找不到指定的文件 - RPy2 on Windows Jupyter notebook: The system cannot find the file specified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM