我有一个我要添加的文件列表
例如,一个是:
project_dir/nextdir/moredir/test.txt
然后我想把它添加到VSS中,最初我试过
ss Add "project_dir/nextdir/moredir/test.txt"
这个问题是,当我希望我的工作目录和文件目录镜像时,这会将文件“test.txt”添加到我设置为“工作目录”的任何目录中。所以,虽然我有
$/SS_Project/test.txt
我想要
$/SS_Project/project_dir/nextdir/moredir/test.txt
无论如何这样做没有首先使用“ss cp /SS_Project/project_dir/nextdir/moredir/test.txt”
感谢您的帮助
答案 0 :(得分:0)
我最终使用了一个bash脚本,看起来像是非常围绕房屋方法。我相信有人可以提供更好的答案,但作为一种解决方法。
以下函数获取需要添加的文件列表,并将它们添加到“源安全”中的相应目录中。如果该文件存在于sourcesafe中尚不存在的目录中,则该目录会自动添加递归。
示例用法(在项目的根目录中):
SSAddEachNewFile file1.txt file2.txt folder1/file3.txt folder1/morefolder/file4.txt
将file1.txt file2.txt folder1 / file3.txt folder1 / morefolder / file4.txt添加到
$ /项目/电流/ myproject的/ FILE1.TXT
$ /项目/电流/ myproject的/ FILE2.TXT
$ /项目/电流/ myproject的/文件夹1 / file3.txt
$ /项目/电流/ myproject的/ folder1中/ morefolder / file4.txt
Bash功能:
SSAddEachNewFile()
{
printf "\n\nAdding files requires us to loop, so we can add to the correct directory"
for file in $1; do
printf "\n--Resetting Dir---\n"
cd %CURRENT_PROJECT_WORKING_DIR
quietsset
printf " ----\n\n"
new_file=$(echo ${file##*/})
directory=$(echo ${file%/*})
#cp to folder
echo "Directory is: $directory"
quietsset
test=$(ss CP $directory 2>&1 | grep -c 'exist' 2>&1)
if (( "1"== $test ));
then
echo "Did not to find directory! It does not exist!....yet :)";
new_directory=$directory;
last_directory=$directory;
while (( "1"== $test ));
do
echo "->This parent directory does not exist, try going up";
echo "---trying to cp to $new_directory"
last_directory=$(echo ${new_directory})
new_directory=$(echo ${new_directory%/*})
quietsset
test=$(ss CP $new_directory 2>&1 | grep -c 'exist' 2>&1)
echo "[+]"
done
echo "Directory does not exit, need to add $last_directory";
ss Add $last_directory -R -C"$SS_COMMENT" -Y$SSNAME
else
echo "Directory already exists, need to add file: ${file}";
ss Add $file -C"$SS_COMMENT" -Y$SSNAME
fi
done
}
它需要一个额外的功能和2个环境变量
quietsset()
{
ss CP $CURRENT_SOURCE_SAFE_PROJECT -O-
}
$ CURRENT_SOURCE_SAFE_PROJECT是您的SS根,$%CURRENT_PROJECT_WORKING_DIR是您的工作目录根目录。
e.g。如果你有项目/当前/ myproject并且你签出了" myproject"文件夹结构。
CURRENT_SOURCE_SAFE_PROJECT = $ / project / current / myproject 和 CURRENT_PROJECT_WORKING_DIR = c / where / you / put / myproject