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.
 
 

29 lines
569 B

#!/bin/sh
set -eu
# find root of the "workspace"
find_repo_workspace_root() {
if [ -d "$1/.repo" ]; then
echo "$1"
elif [ "${1:-/}" != / ]; then
find_repo_workspace_root "${1%/*}"
fi
}
WS="$(find_repo_workspace_root "$PWD")"
if [ -z "$WS" ]; then
# find root of .git repository
WS="$(git rev-parse --show-superproject-working-tree 2> /dev/null || true)"
[ -d "$WS" ] || WS="$(git rev-parse --show-toplevel 2> /dev/null || true)"
fi
if [ -d "$WS" ]; then
if [ -x "$WS/run.sh" ]; then
exec "$WS/run.sh" "$@"
fi
fi
if [ "$#" -gt 0 ]; then
exec "$@"
fi