以递归模式列出文件夹中的所有 SVN 存储库 URL
我们正在寻找一个脚本,它将以递归模式遍历所有子文件夹并列出所有 SVN 存储库 URL 以及找到它的路径。
它将用于用户的 /home 文件夹。
We are looking for a script that will traverse in recursive mode all subfolders and list all SVN repository URLs and the path where it was found.
It will be used on /home folder of a user.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
递归查找目录,并为每个目录尝试获取 SVN 信息。如果成功,则不要下降到目录并打印目录名称。
这将列出目录。
如果您想要存储库信息,可以将其添加到 find exec 命令的中间。
编辑:
通过仅测试
.svn
子目录的存在,我发现了更好的结果。然后,svn info
在最后调用一次,并查找路径和 URL。 (加上使用 -0 来防止文件名中出现空格。)Recursively find directories, and for each of them try to get the SVN info. If it is successfull, then don't descend into the directory and print the directory name.
This will list the directories.
If you want the repository info, you can add it in the middle of the find exec command.
Edit:
I found much better results by only testing for the presence of an
.svn
subdirectory. Then,svn info
is called once at the end and grepped for Path and URL. (Plus using -0 to prevent from spaces in filenames.)根据您的限制类型,可能有不同的方法。最简单的方法是执行 svn ls -R | grep -v "\." 从您所在的存储库位置获取所有子文件夹,并将其输入到
for
循环中,该循环将 URI 添加到根目录ls 到每行的前面。然而,如果您的文件不包含“.”,这还不够。因为它们将被检测为文件夹。不幸的是 svn ls 不允许您按文件/文件夹进行过滤,因此如果您需要处理不带扩展名的文件名,那么您必须执行不同的操作,例如检查源代码并使用 find获取文件夹名称。Depending on what kind of limitations you have there could be different ways. The easiest way would be to do
svn ls -R | grep -v "\."
to grab all the sub-folders from the repository location you're at and feed that in to afor
loop that adds the URI to the root of the ls to the front of each line. This will however not be adequate if you have files that do not contain a "." as they will be detected as folders. Unfortunatelysvn ls
doesn't allow you to filter by file/folder, so if you need to deal with filenames without extensions then you'd have to do something different such as checking out the source and using find to get the folder names.只是希望用户不要将SVN存储在名称中有空格的目录下。
Just hope users do not store SVN under directories with spaces in names.