如何找到给定 subversion 工作副本的根文件夹 [英] How can I find the root folder of a given subversion working copy
问题描述
我经常坐在一个 Subversion 工作副本的中间,我想快速查看 svn status
以了解自上次签入以来我所做的更改.但是 svn status
仅适用于当前文件夹及其子文件夹.(svn up
也类似)
Quite often I'm sitting in the middle of a subversion working copy, and I want to do a quick svn status
to find out what changes I have made since the last checkin. However svn status
only works on the current folder and it's children. (Similarly for svn up
too)
我想要一种快速更改到 subversion 工作副本的根文件夹的方法,以便我可以运行 svn status
并查看已更改的所有文件,也许是签到或更新,然后回到我以前的工作状态.
I'd like a quick way to change to the root folder of the subversion working copy so I can run a svn status
and see all files that have changed, maybe a checkin or a update, and then get back to work where I was before.
推荐答案
这是我第一次回答:我写了一个名为 svnbase
的小 bash 脚本:
Here's my first go at an answer: I wrote a little bash script called svnbase
:
#!/bin/bash -u
# this command outputs the top-most parent of the current folder that is still
# under svn revision control to standard out
# if the current folder is not under svn revision control, nothing is output
# and a non-zero exit value is given
parent=""
grandparent="."
while [ -d "$grandparent/.svn" ]; do
parent=$grandparent
grandparent="$parent/.."
done
if [ ! -z "$parent" ]; then
echo $parent
else
exit 1
fi
所以现在我可以这样做了:
So now I can do this:
[~/work/scripts/XXX/code/speech-detection/framework]$ cd $(svnbase)
[~/work/scripts/XXX]$ svn status
? code/speech-detection/framework/output.old
[~/work/scripts/XXX]$ cd -
/home/XXXX/work/scripts/XXX/code/speech-detection/framework
[~/work/scripts/XXX/code/speech-detection/framework]$
这篇关于如何找到给定 subversion 工作副本的根文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!