Skip to content

Commit

Permalink
Remove ability to change custom openssl path on upgrade #108
Browse files Browse the repository at this point in the history
I reconsidered the feature that let users set or update a custom
openssl path using the --upgrade flag. This was unusual behaviour:
no other transcrypt settings could be altered during upgrade.

Since it is somewhat likely a user will need or want to change their
openssl path over a repository's lifetime, the help text now says
how to do that using a standard git config-setting command.
  • Loading branch information
jmurty committed Feb 19, 2021
1 parent 4b319aa commit 222bf43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
12 changes: 6 additions & 6 deletions tests/test_init.bats
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
}


@test "init: transcrypt.openssl-path config setting is retained or updated with --upgrade" {
@test "init: transcrypt.openssl-path config setting is retained with --upgrade" {
init_transcrypt
[[ "$(git config --get transcrypt.openssl-path)" = 'openssl' ]]

# Manually change openssl path
FULL_OPENSSL_PATH=$(which openssl)
git config transcrypt.openssl-path "$FULL_OPENSSL_PATH"

# Retain transcrypt.openssl-path config setting on upgrade
"$BATS_TEST_DIRNAME"/../transcrypt --upgrade --yes
[[ "$(git config --get transcrypt.openssl-path)" = 'openssl' ]]

# Replace transcrypt.openssl-path config setting if given on upgrade
FULL_OPENSSL_PATH=$(which openssl)
"$BATS_TEST_DIRNAME"/../transcrypt --upgrade --yes --openssl-path="$FULL_OPENSSL_PATH"
[[ "$(git config --get transcrypt.openssl-path)" = "$FULL_OPENSSL_PATH" ]]
[[ ! "$(git config --get transcrypt.openssl-path)" = 'openssl' ]]
}
17 changes: 7 additions & 10 deletions transcrypt
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,8 @@ upgrade_transcrypt() {
# Keep current cipher and password
cipher=$(git config --get --local transcrypt.cipher)
password=$(git config --get --local transcrypt.password)
# Keep current openssl-path, unless an explicit argument was given
if [[ ! $openssl_path_given ]]; then
openssl_path=$(git config --get --local transcrypt.openssl-path 2>/dev/null || printf "openssl")
fi
# Keep current openssl-path, or set to default if no existing value
openssl_path=$(git config --get --local transcrypt.openssl-path 2>/dev/null || printf '%s' "$openssl_path")

# Keep contents of .gitattributes
ORIG_GITATTRIBUTES=$(cat "$GIT_ATTRIBUTES")
Expand Down Expand Up @@ -880,6 +878,11 @@ help() {
the password to derive the key from;
defaults to 30 random base64 characters
--openssl-path=PATH_TO_OPENSSL
use OpenSSL at this path; defaults to 'openssl' in \$PATH.
To change after initialization:
git config transcrypt.openssl-path NEW_PATH
-y, --yes
assume yes and accept defaults for non-specified options
Expand Down Expand Up @@ -920,10 +923,6 @@ help() {
-i, --import-gpg=FILE
import the password and cipher from a gpg encrypted file
--openssl-path=PATH_TO_OPENSSL
use a specific openssl binary instead of the version in \$PATH.
Use this with --upgrade to update transcrypt's openssl path
-v, --version
print the version information
Expand Down Expand Up @@ -986,7 +985,6 @@ show_file=''
uninstall=''
upgrade=''
openssl_path='openssl'
openssl_path_given=''

# used to bypass certain safety checks
requires_existing_config=''
Expand All @@ -1012,7 +1010,6 @@ while [[ "${1:-}" != '' ]]; do
;;
--openssl-path=*)
openssl_path=${1#*=}
openssl_path_given='true'
;;
-y | --yes)
interactive=''
Expand Down

0 comments on commit 222bf43

Please sign in to comment.