-
Notifications
You must be signed in to change notification settings - Fork 0
/
svntools.sh
executable file
·55 lines (52 loc) · 1.72 KB
/
svntools.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#global variable
svn_trunk_prefix='svn://10.1.1.106/baturu/trunk/server'
svn_branch_prefix='svn://10.1.1.106/baturu/branch/server'
#program start
echo -e '\n请输入项目名:'
read projectname
echo -e '\n你输入的分支名为:'$projectname
echo -e '\n请输入要创建的分支名:'
read branchname
echo -e '\n你输入的分支名为:'$branchname' , 正在创建分支,请稍后...'
svn mkdir $svn_branch_prefix/$projectname/$branchname
#通过 $? 获取上一次命令执行的结果,0表示成功,非0表示失败。
if [ $? -eq 0 ]; then #1
echo -e '\n准备创建分支:'$branchname',请输入备注:'
read memo
svn cp -m "$memo" $svn_trunk_prefix/$projectname $svn_branch_prefix/$projectname/$branchname/$projectname
if [ $? -eq 0 ]; then #2
echo -e '\n创建分支成功,是否需要checkout【yes(y)/no(n)】?'
current_branch_address=$svn_branch_prefix/$projectname/$branchname/$projectname
read co
case $co in
yes|y)
echo -e '\n请输入checkout路径:'
read dir
if [ ! -d "$dir" ]; then #判断文件夹是否存在
mkdir "$dir"
fi
#切换到目录,并checkout文件
cd $dir && svn co $current_branch_address
if [ $? -eq 0 ]; then #3
echo -e '\ncheckout完毕!'
echo -e '\n任务执行完毕!'
else #3
echo -e '\ncheckout分支失败。'
fi #3
;;
no|n)
echo -e '\n放弃checkout。'
echo -e '\n本次创建的分支地址:'$current_branch_address
echo -e '\n任务执行完毕!'
;;
*)
;;
esac
else #2
echo -e '\n创建分支失败,原因为:创建分支时出错。'
fi #2
else #1
echo -e '\n创建分支失败,原因为:创建分支文件夹时出错。'
fi #1
#program end