lib-git-svn.sh: Move web-server handling code into separate function
This library file is currently sourced by 57 test files, of which only four may (optionally) start a web-server in order to access the svn repo via an http url, rather than a file url. In addition to isolating the current web-server handling code from the majority of tests, in a new prepare_httpd function, we also add some more error checking and reporting code to validate the apache installation. Only those tests which attempt to start the web-server, by calling start_httpd, will execute this code. Note that it is important for start_httpd to return an error indication, if prepare_httpd fails, so that the failure to use the web-server, as requested by the user, should not go unnoticed. (Unless the svnrepo variable is set to an http url at the end of start_httpd, the remaining tests will use file urls, without comment.) Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f2665ec9fa
commit
3aa3047106
@ -68,8 +68,7 @@ svn_cmd () {
|
|||||||
svn "$orig_svncmd" --config-dir "$svnconf" "$@"
|
svn "$orig_svncmd" --config-dir "$svnconf" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -n "$SVN_HTTPD_PORT"
|
prepare_httpd () {
|
||||||
then
|
|
||||||
for d in \
|
for d in \
|
||||||
"$SVN_HTTPD_PATH" \
|
"$SVN_HTTPD_PATH" \
|
||||||
/usr/sbin/apache2 \
|
/usr/sbin/apache2 \
|
||||||
@ -83,8 +82,8 @@ then
|
|||||||
done
|
done
|
||||||
if test -z "$SVN_HTTPD_PATH"
|
if test -z "$SVN_HTTPD_PATH"
|
||||||
then
|
then
|
||||||
skip_all='skipping git svn tests, Apache not found'
|
echo >&2 '*** error: Apache not found'
|
||||||
test_done
|
return 1
|
||||||
fi
|
fi
|
||||||
for d in \
|
for d in \
|
||||||
"$SVN_HTTPD_MODULE_PATH" \
|
"$SVN_HTTPD_MODULE_PATH" \
|
||||||
@ -99,23 +98,16 @@ then
|
|||||||
done
|
done
|
||||||
if test -z "$SVN_HTTPD_MODULE_PATH"
|
if test -z "$SVN_HTTPD_MODULE_PATH"
|
||||||
then
|
then
|
||||||
skip_all='skipping git svn tests, Apache module dir not found'
|
echo >&2 '*** error: Apache module dir not found'
|
||||||
test_done
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
if test ! -f "$SVN_HTTPD_MODULE_PATH/mod_dav_svn.so"
|
||||||
|
|
||||||
start_httpd () {
|
|
||||||
repo_base_path="$1"
|
|
||||||
if test -z "$SVN_HTTPD_PORT"
|
|
||||||
then
|
then
|
||||||
echo >&2 'SVN_HTTPD_PORT is not defined!'
|
echo >&2 '*** error: Apache module "mod_dav_svn" not found'
|
||||||
return
|
return 1
|
||||||
fi
|
|
||||||
if test -z "$repo_base_path"
|
|
||||||
then
|
|
||||||
repo_base_path=svn
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
repo_base_path="${1-svn}"
|
||||||
mkdir "$GIT_DIR"/logs
|
mkdir "$GIT_DIR"/logs
|
||||||
|
|
||||||
cat > "$GIT_DIR/httpd.conf" <<EOF
|
cat > "$GIT_DIR/httpd.conf" <<EOF
|
||||||
@ -132,12 +124,24 @@ LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so
|
|||||||
SVNPath "$rawsvnrepo"
|
SVNPath "$rawsvnrepo"
|
||||||
</Location>
|
</Location>
|
||||||
EOF
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
start_httpd () {
|
||||||
|
if test -z "$SVN_HTTPD_PORT"
|
||||||
|
then
|
||||||
|
echo >&2 'SVN_HTTPD_PORT is not defined!'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
prepare_httpd "$1" || return 1
|
||||||
|
|
||||||
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start
|
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start
|
||||||
svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path"
|
svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_httpd () {
|
stop_httpd () {
|
||||||
test -z "$SVN_HTTPD_PORT" && return
|
test -z "$SVN_HTTPD_PORT" && return
|
||||||
|
test ! -f "$GIT_DIR/httpd.conf" && return
|
||||||
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k stop
|
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k stop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user