Merge pull request #231 from joshrabinowitz/hide-in-subdir

fix for issue #230 (git secret hide fails in subdir). Also disables builds on alpine-latest for #232
pull/242/head
Josh Rabinowitz 6 years ago committed by GitHub
commit e515eb8f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,12 +7,12 @@ matrix:
sudo: required
language: ruby
rvm: 2.4
- os: linux
env: KITCHEN_REGEXP="gnupg1-alpine-latest"
services: docker
sudo: required
language: ruby
rvm: 2.4
#- os: linux
# env: KITCHEN_REGEXP="gnupg1-alpine-latest"
# services: docker
# sudo: required
# language: ruby
# rvm: 2.4
- os: linux
env: KITCHEN_REGEXP="gnupg1-debian-latest"
services: docker
@ -37,12 +37,12 @@ matrix:
sudo: required
language: ruby
rvm: 2.4
- os: linux
env: KITCHEN_REGEXP="gnupg2-alpine-latest"
services: docker
sudo: required
language: ruby
rvm: 2.4
#- os: linux
# env: KITCHEN_REGEXP="gnupg2-alpine-latest"
# services: docker
# sudo: required
# language: ruby
# rvm: 2.4
- os: linux
env: KITCHEN_REGEXP="gnupg2-debian-latest"; GITSECRET_DIST="deb"
services: docker

@ -120,12 +120,6 @@ function hide {
# make sure all the unencrypted files needed are present
local to_hide=()
while read -r record; do
local filename
filename=$(_get_record_filename "$record")
if [[ ! -f "$filename" ]]; then
_abort "file not found: $filename"
fi
to_hide+=("$record") # add record to array
done < "$path_mappings"
@ -138,11 +132,6 @@ function hide {
fsdb_file_hash=$(_get_record_hash "$record")
encrypted_filename=$(_get_encrypted_filename "$filename")
# Checking that file is valid:
if [[ ! -f "$filename" ]]; then
_abort "file not found: $filename"
fi
local recipients
recipients=$(_get_recipients)
@ -154,6 +143,11 @@ function hide {
input_path=$(_append_root_path "$filename")
output_path=$(_append_root_path "$encrypted_filename")
# Checking that file is valid:
if [[ ! -f "$input_path" ]]; then
_abort "file not found: $input_path"
fi
file_hash=$(_get_file_hash "$input_path")
# encrypt file only if required

@ -37,6 +37,28 @@ function teardown {
[ -f "$encrypted_file" ]
}
@test "run 'hide' from inside subdirectory" {
# Preparations:
local root_dir='test_sub_dir'
mkdir -p "$root_dir"
local second_file="$root_dir/second_file.txt"
local second_content="some content"
set_state_secret_add "$second_file" "$second_content"
# Verify that the second file is there:
[ -f "$second_file" ]
# cd into the subdir
cd "$root_dir"
# Now it should hide 2 files:
run git secret hide
[ "$status" -eq 0 ]
# cd back
cd ".."
}
@test "run 'hide' with missing file" {
# Preparations:
local second_file="second_file.txt"

Loading…
Cancel
Save