1 Star 0 Fork 3

朱良才/useful-scripts

forked from _KK/useful-scripts 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
swtrunk.sh 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
oldratlee 提交于 2018-06-24 23:18 . emojify
#!/bin/bash
# @Function
# switch svn work directory to trunk.
#
# @Usage
# $ ./swtrunk.sh [<svn work dir>...]
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/vcs.md#-swtrunksh
# @author Jerry Lee (oldratlee at gmail dot com)
# NOTE: $'foo' is the escape sequence syntax of bash
readonly ec=$'\033' # escape char
readonly eend=$'\033[0m' # escape end
colorEcho() {
local color=$1
shift
# if stdout is console, turn on color output.
[ -t 1 ] && echo "$ec[1;${color}m$@$eend" || echo "$@"
}
redEcho() {
colorEcho 31 "$@"
}
greenEcho() {
colorEcho 32 "$@"
}
[ $# -eq 0 ] && dirs=(.) || dirs=("$@")
for d in "${dirs[@]}" ; do
[ ! -d ${d}/.svn ] && {
redEcho "directory $d is not a svn work directory, ignore directory $d !"
continue
}
(
cd "$d" &&
branches=`svn info | grep '^URL' | awk '{print $2}'` &&
trunk=`echo $branches | awk -F'/branches/' '{print $1}'`/trunk &&
svn sw "$trunk" &&
greenEcho "svn work directory $d switch from ${branches} to ${trunk} ." ||
redEcho "fail to switch $d to trunk!"
)
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuliangcai/useful-scripts.git
git@gitee.com:zhuliangcai/useful-scripts.git
zhuliangcai
useful-scripts
useful-scripts
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385