以递归模式列出文件夹中的所有 SVN 存储库 URL

发布于 2024-12-14 10:13:17 字数 87 浏览 0 评论 0原文

我们正在寻找一个脚本,它将以递归模式遍历所有子文件夹并列出所有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瞳孔里扚悲伤 2024-12-21 10:13:17

递归查找目录,并为每个目录尝试获取 SVN 信息。如果成功,则不要下降到目录并打印目录名称。

find -type d -exec bash -c "svn info {} > /dev/null 2> /dev/null" \; -prune -print

这将列出目录。

如果您想要存储库信息,可以将其添加到 find exec 命令的中间。

find -type d -exec bash -c "svn info {} 2> /dev/null | grep URL" \; -prune -print

编辑:

通过仅测试 .svn 子目录的存在,我发现了更好的结果。然后,svn info 在最后调用一次,并查找路径和 URL。 (加上使用 -0 来防止文件名中出现空格。)

find -type d -exec test -d "{}/.svn" \; -prune -print0 | xargs -0 svn info | grep -e '\(Path\|URL\)'

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.

find -type d -exec bash -c "svn info {} > /dev/null 2> /dev/null" \; -prune -print

This will list the directories.

If you want the repository info, you can add it in the middle of the find exec command.

find -type d -exec bash -c "svn info {} 2> /dev/null | grep URL" \; -prune -print

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.)

find -type d -exec test -d "{}/.svn" \; -prune -print0 | xargs -0 svn info | grep -e '\(Path\|URL\)'
就此别过 2024-12-21 10:13:17

根据您的限制类型,可能有不同的方法。最简单的方法是执行 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 a for 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. Unfortunately svn 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.

寄居人 2024-12-21 10:13:17
user_home=... # fill in the user's home dir
old_dir=/../
find $user_home -name .svn | rev | cut -f2- -d/ | rev | while read line ; do
    echo -n "$line"

只是希望用户不要将SVN存储在名称中有空格的目录下。

\t' wc -c <<<"$line" done | sort -t

只是希望用户不要将SVN存储在名称中有空格的目录下。

\t' -k1,1 -k2,2n | while read dir size ; do if [[ $dir != $old_dir* ]] ; then old_dir=$dir svn info $dir | grep URL echo PATH: $dir echo fi done

只是希望用户不要将SVN存储在名称中有空格的目录下。

user_home=... # fill in the user's home dir
old_dir=/../
find $user_home -name .svn | rev | cut -f2- -d/ | rev | while read line ; do
    echo -n "$line"

Just hope users do not store SVN under directories with spaces in names.

\t' wc -c <<<"$line" done | sort -t

Just hope users do not store SVN under directories with spaces in names.

\t' -k1,1 -k2,2n | while read dir size ; do if [[ $dir != $old_dir* ]] ; then old_dir=$dir svn info $dir | grep URL echo PATH: $dir echo fi done

Just hope users do not store SVN under directories with spaces in names.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文