BACKWARDS INCOMPATIBLE CHANGES:
* Using $BASEDIR to pass the location of the repo hasn't worked for a while. It has been removed. Simply cd into the vcs repo before running a command. BUG FIXES: * .gitignore was being created in subdirectories instead of VCS root. MINOR CHANGES * _blackbox_common.sh: Replace change_to_root with change_to_vcs_root * confidence_test.sh: Added more assertions and tests.
This commit is contained in:
@@ -27,7 +27,7 @@ function _determine_vcs_base_and_type() {
|
||||
#find topmost dir with .svn sub-dir
|
||||
parent=""
|
||||
grandparent="."
|
||||
mydir=$(pwd)
|
||||
mydir="$(pwd)"
|
||||
while [ -d "$grandparent/.svn" ]; do
|
||||
parent=$grandparent
|
||||
grandparent="$parent/.."
|
||||
@@ -35,7 +35,7 @@ function _determine_vcs_base_and_type() {
|
||||
|
||||
if [ ! -z "$parent" ]; then
|
||||
cd "$parent"
|
||||
echo "$(pwd)"
|
||||
pwd
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
@@ -256,6 +256,15 @@ function enumerate_subdirs() {
|
||||
done <"$listfile" | sort -u
|
||||
}
|
||||
|
||||
# chdir to the base of the repo.
|
||||
function change_to_vcs_root() {
|
||||
if [[ $REPOBASE = '' ]]; then
|
||||
echo 'ERROR: _determine_vcs_base_and_type failed to set REPOBASE.'
|
||||
exit 1
|
||||
fi
|
||||
cd "$REPOBASE"
|
||||
}
|
||||
|
||||
# Output the path of a file relative to the repo base
|
||||
function vcs_relative_path() {
|
||||
# Usage: vcs_relative_path file
|
||||
@@ -378,7 +387,6 @@ function vcs_commit_svn() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Remove file from repo, even if it was deleted locally already.
|
||||
# If it doesn't exist yet in the repo, it should be a no-op.
|
||||
function vcs_remove() {
|
||||
@@ -396,17 +404,3 @@ function vcs_remove_git() {
|
||||
function vcs_remove_svn() {
|
||||
svn delete """$@"""
|
||||
}
|
||||
|
||||
function change_to_root() {
|
||||
# If BASEDIR is not set, use REPOBASE.
|
||||
if [[ "$BASEDIR" = "" ]]; then
|
||||
BASEDIR="$REPOBASE"
|
||||
fi
|
||||
|
||||
if [[ "$BASEDIR" = "/dev/null" ]]; then
|
||||
echo 'WARNING: Not in a VCS repo. Not changing directory.'
|
||||
else
|
||||
echo "CDing to $BASEDIR"
|
||||
cd "$BASEDIR"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -22,15 +22,14 @@ if [[ $1 != 'yes' ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
echo cd "$REPOBASE"
|
||||
cd "$REPOBASE"
|
||||
change_to_vcs_root
|
||||
|
||||
echo VCS_TYPE: $VCS_TYPE
|
||||
|
||||
if [[ $VCS_TYPE = "git" || $VCS_TYPE = "hg" ]]; then
|
||||
# Update .gitignore or .hgignore
|
||||
|
||||
IGNOREFILE=".${VCS_TYPE}ignore"
|
||||
IGNOREFILE="${REPOBASE}/.${VCS_TYPE}ignore"
|
||||
if ! grep -sx >/dev/null 'pubring.gpg~' "$IGNOREFILE" ; then
|
||||
echo 'pubring.gpg~' >>"$IGNOREFILE"
|
||||
fi
|
||||
|
||||
@@ -23,7 +23,7 @@ else
|
||||
FILE_GROUP="$1"
|
||||
fi
|
||||
|
||||
change_to_root
|
||||
change_to_vcs_root
|
||||
prepare_keychain
|
||||
|
||||
# Decrypt:
|
||||
|
||||
@@ -50,9 +50,11 @@ fi
|
||||
|
||||
# TODO(tlim): This should be moved to _blackbox_common.sh in a
|
||||
# VCS-independent way.
|
||||
IGNOREFILE=".${VCS_TYPE}ignore"
|
||||
IGNOREFILE="${REPOBASE}/.${VCS_TYPE}ignore"
|
||||
if [[ $VCS_TYPE = 'git' ]]; then
|
||||
ignored_file="$(echo "$unencrypted_file" | sed 's/\([\*\?]\)/\\\1/g' | sed 's/^\([!#]\)/\\\1/')"
|
||||
relfile="$(vcs_relative_path "$unencrypted_file")"
|
||||
relfileb="${relfile/\$\//}"
|
||||
ignored_file="$(echo "${relfileb}" | sed 's/\([\*\?]\)/\\\1/g' | sed 's/^\([!#]\)/\\\1/')"
|
||||
if ! grep -Fsx >/dev/null "$ignored_file" "$IGNOREFILE"; then
|
||||
echo "$ignored_file" >>"$IGNOREFILE"
|
||||
COMMIT_FILES+=("$IGNOREFILE")
|
||||
|
||||
@@ -19,7 +19,7 @@ set -e
|
||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
source "${blackbox_home}/_blackbox_common.sh"
|
||||
|
||||
change_to_root
|
||||
change_to_vcs_root
|
||||
|
||||
echo '========== FILES BEING SHREDDED:'
|
||||
for i in $(<"$BB_FILES") ; do
|
||||
|
||||
@@ -214,6 +214,7 @@ PHASE 'She enrolls secrets.txt.'
|
||||
blackbox_register_new_file secret.txt
|
||||
assert_file_missing secret.txt
|
||||
assert_file_exists secret.txt.gpg
|
||||
assert_line_exists 'secret.txt' .gitignore
|
||||
|
||||
PHASE 'She decrypts secrets.txt.'
|
||||
blackbox_edit_start secret.txt
|
||||
@@ -297,6 +298,7 @@ blackbox_register_new_file mistake.txt
|
||||
assert_file_missing mistake.txt
|
||||
assert_file_exists mistake.txt.gpg
|
||||
# NOTE: It is still in the history. That should be corrected someday.
|
||||
assert_line_exists 'mistake.txt' .gitignore
|
||||
|
||||
PHASE 'Bob enrolls my/path/to/relsecrets.txt.'
|
||||
mkdir my my/path my/path/to
|
||||
@@ -305,6 +307,9 @@ cd my/path/to
|
||||
blackbox_register_new_file relsecrets.txt
|
||||
assert_file_missing relsecrets.txt
|
||||
assert_file_exists relsecrets.txt.gpg
|
||||
assert_file_missing .gitignore
|
||||
assert_file_exists ../../../.gitignore
|
||||
assert_line_exists 'my/path/to/relsecrets.txt' ../../../.gitignore
|
||||
|
||||
PHASE 'Bob decrypts relsecrets.txt.'
|
||||
cd ..
|
||||
@@ -355,5 +360,5 @@ fi
|
||||
|
||||
find .git?* * -type f -ls
|
||||
echo cd "$test_repository"
|
||||
echo rm "$test_repository"
|
||||
echo rm -rf "$test_repository"
|
||||
echo DONE.
|
||||
|
||||
Reference in New Issue
Block a user