导出未提交文件
export.sh
#仓库路径
REPO_PATH=$1
#文件的类型
FOLDER="/CYWORK/GIT_EXPORT_FILES"
FOLDER_DATE=`date +%Y%m%d_%H_%M_%S`
PROJECT_NAME=${REPO_PATH##*/}
for arg in "[email protected]"
do
if [ $1 != $arg ]
then
srcfile="$REPO_PATH/$arg"
cpfile="$FOLDER/${PROJECT_NAME}_$FOLDER_DATE/$arg"
folder=${cpfile%/*}
`mkdir -p $folder`
result=`cp -f $srcfile $cpfile`
echo "$arg"
fi
done
|
按版本号内容导出文件
#仓库路径
REPO_PATH=$1
GIT_SHA=$2
#文件的类型
FOLDER="/CYWORK/GIT_EXPORT_FILES"
FOLDER_DATE=`date +%Y%m%d_%H_%M_%S`
PROJECT_NAME=${REPO_PATH##*/}
`mkdir -p $FOLDER`
filepath=$(cd $REPO_PATH; pwd)
split_str=`git show --format= --name-status $GIT_SHA`
echo "$split_str" > "$FOLDER/tmp.txt"
split_array=()
split_len=0
while read line
do
split_array[$split_len]=$line
split_len=$split_len+1
done < "$FOLDER/tmp.txt"
for ((i=0;i<${#split_array[@]};i++));do
{
string=${split_array[$i]}
array=(${string//,/ })
if [ "$array[0]" != "D" ]
then
echo ${array[1]}
srcfile="$REPO_PATH/${array[1]}"
cpfile="$FOLDER/${PROJECT_NAME}_$FOLDER_DATE/${array[1]}"
folder=${cpfile%/*}
`mkdir -p $folder`
`cp -f $srcfile $cpfile`
fi
# for var in ${array[@]}
# do
# echo $var
# done
}
done
|