summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2012-02-03 12:59:22 +0100
committerJan Pokorný <jpokorny@redhat.com>2012-02-03 12:59:22 +0100
commit9687b559ecff22cd42c0a0acdfd2980565bf1146 (patch)
tree010c8e8aacf48f23d0455d62b1c000ac6365567e
parentfc2d9a48e9a5504f0ae4356278aa854cf2def1b1 (diff)
downloadvim4projects-9687b559ecff22cd42c0a0acdfd2980565bf1146.tar.gz
vim4projects-9687b559ecff22cd42c0a0acdfd2980565bf1146.tar.xz
vim4projects-9687b559ecff22cd42c0a0acdfd2980565bf1146.zip
explicit SVN revisions, minor changes
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--.gitignore6
-rw-r--r--init-common7
-rw-r--r--init-optional3
-rw-r--r--init-python3
-rw-r--r--init-tg26
-rw-r--r--init-web3
-rwxr-xr-xinit.sh71
7 files changed, 57 insertions, 42 deletions
diff --git a/.gitignore b/.gitignore
index 4b9d9e2..5a5de30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-/genshi-contrib
-/local-vimrc
+*
+! /git-*/
+! /.gitignore
+! /init*
diff --git a/init-common b/init-common
index 0a247d8..f5cec4a 100644
--- a/init-common
+++ b/init-common
@@ -1,6 +1,4 @@
# common vim plugins for shared projects
-CHOICES="$CHOICES|common"
-
common () {
announce "--- common ---"
# local_vimrc:
@@ -10,6 +8,7 @@ common () {
LH_COMMON_URL="http://lh-vim.googlecode.com/svn/vim-lib/trunk/autoload/lh/common.vim"
# "plugin" directory has to be added (downloading recursively
# the whole original "plugin" path for one file is impractical)
- do_wget $1 "$LOCAL_VIMRC_DIR/plugin" -nc "$LOCAL_VIMRC_URL"
- do_wget $1 "$LOCAL_VIMRC_DIR/autoload/lh" -nc "$LH_COMMON_URL"
+ do_wget $1 "$LOCAL_VIMRC_DIR/plugin" "$LOCAL_VIMRC_URL"
+ do_wget $1 "$LOCAL_VIMRC_DIR/autoload/lh" "$LH_COMMON_URL"
}
+register common
diff --git a/init-optional b/init-optional
index 389c873..a36e50e 100644
--- a/init-optional
+++ b/init-optional
@@ -1,6 +1,4 @@
# optional (but recommended) vim plugins
-CHOICES="$CHOICES|optional"
-
optional () {
announce "--- optional ---"
# makegreen:
@@ -9,3 +7,4 @@ optional () {
# "code navigator" incl. JS support if jsctags installed
do_git_submodule $1 "git-makegreen" "git-tagbar"
}
+register optional
diff --git a/init-python b/init-python
index b82705f..77b1dca 100644
--- a/init-python
+++ b/init-python
@@ -1,6 +1,4 @@
# vim plugins for Python projects
-CHOICES="$CHOICES|python"
-
python () {
announce "--- python ---"
# Python-mode:
@@ -8,3 +6,4 @@ python () {
# + extra highlighting, whitespace removal ...
do_git_submodule $1 "git-python-mode"
}
+register python
diff --git a/init-tg2 b/init-tg2
index fb63647..10e79eb 100644
--- a/init-tg2
+++ b/init-tg2
@@ -1,12 +1,10 @@
# vim plugins for TG2 projects
-CHOICES="$CHOICES|tg2"
-
tg2 () {
announce "--- tg2 ---"
# genshi-contrib:
# from genshi svn, contrib/vim
- # TODO: is there a less complicated way to get these files?
GENSHI_CONTRIB_DIR="genshi-contrib"
GENSHI_CONTRIB_URL="http://svn.edgewall.org/repos/genshi/contrib/vim/"
- do_wget $1 "$GENSHI_CONTRIB_DIR" -nc -e robots=off -r -l3 -np -nH --cut-dirs=4 -R index.html "$GENSHI_CONTRIB_URL"
+ do_svn $1 "$GENSHI_CONTRIB_DIR" "$GENSHI_CONTRIB_SVN"
}
+register tg2
diff --git a/init-web b/init-web
index c8e66d6..7eb7e6c 100644
--- a/init-web
+++ b/init-web
@@ -1,7 +1,6 @@
# vim plugins for web projects
-CHOICES="$CHOICES|web"
-
web () {
announce "--- web ---"
# empty for now
}
+#register web
diff --git a/init.sh b/init.sh
index 33a2d82..c5cc4a1 100755
--- a/init.sh
+++ b/init.sh
@@ -1,21 +1,12 @@
#!/bin/sh
+# vim:set noet ts=4 sts=4:
# jpokorny@redhat.com
#
-# base functions
+# internals
#
-announce () {
- # use colours if available
- echo
- if test -t 1; then
- echo -en "\\033[32m"
- echo -n "$1"
- echo -e "\\033[0m"
- else
- echo "[[ $1 ]]"
- fi
-}
+CHOICES=""
check_nargs () {
[ $1 -ge $2 ]
@@ -34,12 +25,39 @@ do_del () {
[ -d "$1" ] && rm -rfI -- "$1" || echo "$1 not present"
}
+#
+# "API" for sourced choices
+#
+
+register () {
+ # usage: $1=choice to register
+ CHOICES="$CHOICES|$1"
+}
+
+announce () {
+ # usage: $1=message to output
+ # use colours if available
+ echo
+ if test -t 1; then
+ echo -en "\\033[32m"
+ echo -n "$1"
+ echo -e "\\033[0m"
+ else
+ echo "[[ $1 ]]"
+ fi
+}
+
do_git_submodule () {
- # usage: $1 = action, $2..n submodules
+ # usage: $1=action ($1 passed from main), $2..$N=submodule(s)
ret=0
+ # TODO: pushd $GIT_ROOT
for submodule in "${@:2}"; do
announce "$1 $submodule (git submodule)"
if [ "$1" == "get" ]; then
+ # TODO: avoid this workaround
+ if [ ! -f .gitmodules ]; then
+ submodule="$SUBMODULES_DIR/$submodule"
+ fi
git submodule update --init "$submodule" 2>&1
else
do_del "$submodule"
@@ -47,21 +65,21 @@ do_git_submodule () {
ret=$?
[ $ret -ne 0 ] && break
done
+ popd
check_ret $ret
}
do_wget () {
- # usage: $1 = action, $2 = target dir, $3..n = actual arguments to wget
+ # usage: $1=action ($1 passed from main), $2=DIR, $3..$N=arguments (to wget)
check_nargs $# 3 || return $?
- if [ "$(dirname $2)" == "." ]; then
- toplevel="$2"
- else
+ toplevel="$2"
+ if [ "$(dirname $2)" != "." ]; then
toplevel="$(dirname $2)"
fi
announce "$1 $toplevel (wget)"
-
if [ "$1" == "get" ]; then
- wget --no-verbose --directory-prefix "$2" "${@:3}" 2>&1
+ wget --no-verbose --no-clobber --execute robots=off \
+ --directory-prefix "$2" "${@:3}" 2>&1
else
do_del "$toplevel"
fi
@@ -69,18 +87,19 @@ do_wget () {
}
do_svn () {
- # usage: $1 = action, $2 = target dir, $3 = svn repo (+ possibly args)
- # TODO: support for revisions?
+ # usage: $1=action ($1 passed from main), $2=DIR, $3=SVN [, $4=REV]
check_nargs $# 3 || return $?
- if [ "$(dirname $2)" == "." ]; then
- toplevel="$2"
- else
+ toplevel="$2"
+ if [ "$(dirname $2)" != "." ]; then
toplevel="$(dirname $2)"
fi
announce "$1 $toplevel (svn)"
-
if [ "$1" == "get" ]; then
- svn checkout --force "${@:3}" "$2" 2>&1
+ rev=""
+ if [ $# -ge 4 ]; then
+ rev="--revision $4"
+ fi
+ svn checkout --force $rev "$3" "$2" | grep "revision"
else
do_del "$toplevel"
fi