functions.sh: make it possible to set git binary

to help with testing
This commit is contained in:
Natanael Copa 2022-06-14 16:57:56 +02:00
parent 9dc6b74058
commit b9739f2c3f
2 changed files with 4 additions and 13 deletions

View File

@ -91,14 +91,16 @@ readconfig() {
[ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF"
[ -f "$ABUILD_USERCONF" ] && . "$ABUILD_USERCONF"
APORTSDIR=${_APORTSDIR-$APORTSDIR}
gitbase=$(git rev-parse --show-toplevel 2>/dev/null) || true # already is -P
: ${GIT:=git}
gitbase=$($GIT rev-parse --show-toplevel 2>/dev/null) || true # already is -P
if [ -d "$APORTSDIR" ]; then
APORTSDIR=$(cd "$APORTSDIR"; pwd -P)
elif [ -z "$APORTSDIR" ] && [ -d "$HOME/aports" ]; then
APORTSDIR=$(cd "$HOME/aports"; pwd -P)
else
if [ -n "$gitbase" ]; then
case $(git remote get-url origin) in
case $($GIT remote get-url origin) in
# '.git' for SSH URLs, and no suffix for HTTPS URLs
*/aports|*/aports.git) APORTSDIR=$gitbase ;;
*) APORTSDIR= ;;

View File

@ -1,11 +0,0 @@
setup() {
export FUNCS=../functions.sh
}
@test "functions: check if CBUILD is set" {
. $FUNCS && test -n "$CBUILD"
}
@test "functions: check that missing gcc does not kill us" {
sh -e -c "CC=false; . $FUNCS && test -z \"$CBUILD\""
}