You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
538 B
23 lines
538 B
vcs() {
|
|
local VCS REF
|
|
|
|
git_dir() {
|
|
[ 'true' != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ] && return 1
|
|
REF=$(git symbolic-ref -q HEAD || git name-rev --name-only HEAD 2>/dev/null)
|
|
REF=${REF#refs/heads/}
|
|
VCS="git"
|
|
}
|
|
|
|
svn_dir() {
|
|
local INFO
|
|
INFO="$(svn info 2>/dev/null)" || return 1
|
|
REF=$(echo "${INFO}" | awk '/^Repository Root/ { sub(".*/","",$0); r=$0 } /^Revision/ { sub("[^0-9]*","",$0); print r":"$0 }')
|
|
VCS="svn"
|
|
}
|
|
|
|
git_dir || svn_dir
|
|
|
|
echo "${VCS:+[${VCS}|${REF}]}"
|
|
}
|
|
|
|
# vim: set ft=sh ts=4 sw=4:
|