Tmp cleanups (#457)

* Only show 'cleaning up temp file' messages if one
  of SECRETS_VERBOSE or SECRETS_TEST_VERBOSE is set.
* Adjust tests to reflect the change.
* Add note about suppressing 'cleaning up' msgs to CHANGELOG.md and reorder entries
* add comments showing examples of tmpfiles returned
pull/458/head
Josh Rabinowitz 5 years ago committed by GitHub
parent 24bfc86b74
commit bbb4d9d3e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,15 +34,16 @@
## Misc
- Use Shellcheck on tests/ files, changes for Shellcheck in tests/ (#368)
- Use Shellcheck on MacOS/osx travis tests (#403)
- Show commands run by Makefile as per debian upstream recommendations (#386)
- Document SECRETS_VERBOSE and improve env var docs (#396)
- Setting SECRETS_TEST_VERBOSE env var shows debug info during tests (EXPERIMENTAL)
- Suppress 'cleaning up temp files' messages unless in a verbose mode.
- Improve git-secret user messaging.
- Update CHANGELOG.md to mention fix for #281 in v0.2.5 (#311)
- Add text explaining git-secret Style Guide and Development Philosophy
- Use Shellcheck on tests/ files, changes for Shellcheck in tests/ (#368)
- Use Shellcheck on MacOS/osx travis tests (#403)
- Show commands run by Makefile as per debian upstream recommendations (#386)
- Upgrade bats-core to v1.1.0, import bats-core into vendor/bats-core (#377)
- Improve git-secret user messaging.
- Setting SECRETS_TEST_VERBOSE env var shows debug info during tests (EXPERIMENTAL)
## Version 0.2.5

@ -196,7 +196,7 @@ function _temporary_file {
# which will be removed on system exit.
temporary_filename=$(_os_based __temp_file) # is not `local` on purpose.
trap 'echo "git-secret: cleaning up: $temporary_filename"; rm -f "$temporary_filename";' EXIT
trap 'if [[ -n "$_SECRETS_VERBOSE" ]] || [[ -n "$SECRETS_TEST_VERBOSE" ]]; then echo "git-secret: cleaning up: $temporary_filename"; fi; rm -f "$temporary_filename";' EXIT
}

@ -10,7 +10,7 @@ function __replace_in_file_linux {
function __temp_file_linux {
: "${TMPDIR:=/tmp}"
local filename
filename=$(mktemp -t _git_secret_XXX )
filename=$(mktemp -t _git_secret_XXX ) # makes a filename like /tmp/_git_secret_6Hw
echo "$filename"
}

@ -10,7 +10,7 @@ function __replace_in_file_osx {
function __temp_file_osx {
: "${TMPDIR:=/tmp}"
local filename
filename=$(mktemp -t _git_secret_XXX )
filename=$(mktemp -t _git_secret ) # makes a filename like '/var/folders/nz/vv4_91234569k3tkvyszvwg90009gn/T/_git_secret.HhvUPlUI'
echo "$filename";
}

@ -153,10 +153,8 @@ function teardown {
# Command must execute normally:
[ "$status" -eq 0 ]
# git secret hide -m, use temp file so cleaning should take place
[[ "${#lines[@]}" -eq 2 ]]
# git secret hide -m: uses temp file so cleaning should take place, but we only show tmp file cleanup in VERBOSE mode
[ "${lines[0]}" = "git-secret: done. 1 of 1 files are hidden." ]
[[ "${lines[1]}" == "git-secret: cleaning up:"* ]]
# New files should be created:
local encrypted_file=$(_get_encrypted_filename "$FILE_TO_HIDE")
@ -173,10 +171,9 @@ function teardown {
# Command must execute normally:
[ "$status" -eq 0 ]
# git secret hide -m, uses a temp file so cleaning should take place
[[ "${#lines[@]}" -eq 2 ]]
# git secret hide -m: uses temp file so cleaning should take place, but we only show tmp file cleanup in VERBOSE mode
[ "${lines[0]}" = "git-secret: done. 1 of 1 files are hidden." ]
[[ "${lines[1]}" == "git-secret: cleaning up:"* ]]
# back path mappings
cp "${path_mappings}" "${path_mappings}.bak"
# run hide again

@ -4,11 +4,14 @@
INSTALL_BASE="${TMPDIR}/git-secret-test-install"
@test "install git-secret to '$INSTALL_BASE'" {
@test "install git-secret to '$TMPDIR'" {
rm -f "${INSTALL_BASE}/usr/bin/git-secret"
cd $SECRET_PROJECT_ROOT && DESTDIR="${INSTALL_BASE}" make install
cd $SECRET_PROJECT_ROOT
# set DESTDIR for this command and 'run' make install
DESTDIR="${INSTALL_BASE}" run make install
[ -x "${INSTALL_BASE}/usr/bin/git-secret" ]
}

Loading…
Cancel
Save