From 2b28271d8bfd8b8afa51d5aabb9089ac5f22889c Mon Sep 17 00:00:00 2001 From: joshr Date: Thu, 12 Jul 2018 09:46:49 -0400 Subject: [PATCH 1/5] create a test displaying issue #230 --- tests/test_hide.bats | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_hide.bats b/tests/test_hide.bats index e822e1ca..c8a0e9ca 100644 --- a/tests/test_hide.bats +++ b/tests/test_hide.bats @@ -37,6 +37,33 @@ 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 ".." + + # It should be verbose: + #[[ "$output" == *"removing unencrypted files"* ]] + #[[ "$output" == *"$FILE_TO_HIDE"* ]] + #[[ "$output" == *"$second_file"* ]] +} + @test "run 'hide' with missing file" { # Preparations: local second_file="second_file.txt" From a7eaa6013c3de226c4e96b451bacbdf5ab2aaac3 Mon Sep 17 00:00:00 2001 From: joshr Date: Thu, 12 Jul 2018 09:52:19 -0400 Subject: [PATCH 2/5] fix for issue #230, when git-secret is run in subdir of repo --- src/commands/git_secret_hide.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/commands/git_secret_hide.sh b/src/commands/git_secret_hide.sh index a69da726..4fcd7145 100644 --- a/src/commands/git_secret_hide.sh +++ b/src/commands/git_secret_hide.sh @@ -123,9 +123,6 @@ function hide { 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 +135,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 +146,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 From 7648e2f604086ef30c70fa79d00e8f865f7e9fa1 Mon Sep 17 00:00:00 2001 From: joshr Date: Thu, 12 Jul 2018 10:22:36 -0400 Subject: [PATCH 3/5] cleanup --- tests/test_hide.bats | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_hide.bats b/tests/test_hide.bats index c8a0e9ca..9fdea916 100644 --- a/tests/test_hide.bats +++ b/tests/test_hide.bats @@ -57,11 +57,6 @@ function teardown { # cd back cd ".." - - # It should be verbose: - #[[ "$output" == *"removing unencrypted files"* ]] - #[[ "$output" == *"$FILE_TO_HIDE"* ]] - #[[ "$output" == *"$second_file"* ]] } @test "run 'hide' with missing file" { From 142944c575eec4358a61cf2260f590a799ddb39e Mon Sep 17 00:00:00 2001 From: joshr Date: Fri, 13 Jul 2018 07:38:24 -0400 Subject: [PATCH 4/5] disable travis-ci tests on alpine-latest --- .travis.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 271445c6..6d892f6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 From 826dfeb5d4987449bd8c4d2104025777740b748c Mon Sep 17 00:00:00 2001 From: joshr Date: Fri, 13 Jul 2018 08:24:30 -0400 Subject: [PATCH 5/5] remove unneeded code --- src/commands/git_secret_hide.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/commands/git_secret_hide.sh b/src/commands/git_secret_hide.sh index 4fcd7145..8f227e87 100644 --- a/src/commands/git_secret_hide.sh +++ b/src/commands/git_secret_hide.sh @@ -120,9 +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") - to_hide+=("$record") # add record to array done < "$path_mappings"