From 5ce3c9370f425bee63b8e0f93ddbff56c9d4e0e3 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 27 May 2020 08:03:12 -0400 Subject: [PATCH] Revert "[wip] Fix how `vcs_relative_path` first resolves an absolute path" This reverts commit a7fd51456949a0fcd30c0074cb61a2f5aad947e9. Sadly this doesn't work in all cases (if the file doesn't exist) and fails on MacOS (I think). --- bin/_blackbox_common.sh | 19 +++++-------------- tools/confidence_test.sh | 1 - 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index a3939cb..b935f5d 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -366,22 +366,13 @@ function enumerate_blackbox_repos() { done } -# Resolve the absolute path of a relative one -# Adapted from https://unix.stackexchange.com/a/483514 -function abs() { - local _pwd bn - [ -d "${1}" ] && _pwd="${1}" - [ -f "${1}" ] && { _pwd=$(dirname "${1}") ; bn=/$(basename "${1}") ;} - pushd "$_pwd" >/dev/null || exit - echo "$(pwd)${bn}" - popd >/dev/null || exit -} - # Output the path of a file relative to the repo base function vcs_relative_path() { - local name - name=$(abs "$1") - name="${name#$REPOBASE}" + # Usage: vcs_relative_path file + local name="$1" + #python -c 'import os ; print(os.path.relpath("'"$(pwd -P)"'/'"$name"'", "'"$REPOBASE"'"))' + local p=$( printf "%s" "$( pwd -P )/${1}" | sed 's#//*#/#g' ) + local name="${p#$REPOBASE}" name=$( printf "%s" "$name" | sed 's#^/##g' | sed 's#/$##g' ) printf "%s" "$name" } diff --git a/tools/confidence_test.sh b/tools/confidence_test.sh index eaeef23..aa8412e 100755 --- a/tools/confidence_test.sh +++ b/tools/confidence_test.sh @@ -160,7 +160,6 @@ blackbox_register_new_file secret.txt assert_file_missing secret.txt assert_file_exists secret.txt.gpg assert_line_exists '/secret.txt' .gitignore -assert_line_exists 'secret.txt' keyrings/live/blackbox-files.txt PHASE 'She cats secrets.txt.gpg.' make_self_deleting_tempfile catsecret