2014-11-21 11 views
0

제가 예를 하나SourceSafe를 명령 라인을 통해 특정 프로젝트 디렉토리에 파일을 추가

테이크를 추가 할 파일의 목록입니다 있습니다

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

처럼 보이는 bash 스크립트를 사용했습니다. VERY 라운드 집 방법. 나는 누군가가 더 좋은 대답을 제공 할 수 있다고 확신하지만 주위의 일로 생각합니다.

다음 함수는 추가해야 할 파일 목록을 가져와 Source Safe의 해당 디렉토리에 추가합니다. 해당 파일이 sourcesafe에 아직 존재하지 않는 디렉토리에 존재하면 해당 디렉토리는 자동으로 에 자동으로 추가됩니다.

사용 예제 (프로젝트의 루트에있는 동안) :

SSAddEachNewFile file1.txt file2.txt folder1/file3.txt folder1/morefolder/file4.txt 

에은 File2.txt file2.txt 폴더 1/file3.txt 폴더 1/morefolder/file4.txt 추가 할

$/프로젝트/현재/MyProject를 /은 file2.txt
$/프로젝트/전류/myproject라는/file2.txt
$/프로젝트/전류/myproject라는/폴더 1/file3.txt
$/프로젝트/전류/myproject라는/폴더 1/morefolder/file4 .txt

배쉬 기능 :

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 

}

그것은 하나 개의 추가 기능이 환경 변수를 필요로

quietsset() 
{ 
    ss CP $CURRENT_SOURCE_SAFE_PROJECT -O- 
} 
$ CURRENT_SOURCE_SAFE_PROJECT이 SS 루트와 $ %의 CURRENT_PROJECT_WORKING_DIR입니다

는 작업 디렉토리의 루트입니다 .

프로젝트/현재/myproject가 있고 체크 아웃하면 "myproject"폴더 구조가 있습니다. 그런 다음

CURRENT_SOURCE_SAFE_PROJECT = $/프로젝트/전류/myproject라는 및 CURRENT_PROJECT_WORKING_DIR = C/어디에서/당신은/넣어/myproject라는