fix: Git directory detection should not print an error if we are not in a git repo

This commit is contained in:
Karolin Varner
2023-05-24 00:00:15 +02:00
committed by Karolin Varner
parent b29720b0c6
commit 19fe7360d2

11
rp
View File

@@ -44,9 +44,14 @@ dbg() {
}
add_warning_tag() {
detect_git_dir() {
# https://stackoverflow.com/questions/3618078/pipe-only-stderr-through-a-filter
("$@" 3>&1 1>&2 2>&3 3>&- | sed 's@^@WARNING: @') 3>&1 1>&2 2>&3 3>&-
(
git -C "${scriptdir}" rev-parse --show-toplevel 3>&1 1>&2 2>&3 3>&- \
| sed '
/not a git repository/d;
s/^/WARNING: /'
) 3>&1 1>&2 2>&3 3>&-
}
# Cleanup subsystem (sigterm)
@@ -320,7 +325,7 @@ main() {
project_name="rosenpass"
verbose=0
scriptdir="$(dirname "${script}")"
gitdir="$(add_warning_tag git -C "${scriptdir}" rev-parse --show-toplevel)" || true
gitdir="$(detect_git_dir)" || true
nixdir="$(readlink -f result/bin/rp | grep -Pio '^/nix/store/[^/]+(?=/bin/[^/]+)')" || true
binary="$(find_rosenpass_binary)"