1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2025-12-18 12:05:19 +02:00

Automatically upgrade v1 hashes (SHA-1) to v2 (cksum) (#55)

A new parameter is added to `_autoenv_hash_pair` to specify the version, defaulting to the latest (2). It outputs a `cksum`-based hash for version 2 and `shasum`-based for version 1.
Moves logic to check for an entry in `$AUTOENV_AUTH_FILE` into its own function (`_autoenv_authorized_pair`), as it may need to be called twice.
Modifies `_autoenv_authorized_env_file` to check for v1 entries when v2 fails.

Fixes #53. Alternative implementation to #54.
This commit is contained in:
Rob Speed
2017-01-10 06:07:39 -05:00
committed by Daniel Hahler
parent 398b6f4f54
commit dfb5648505
4 changed files with 97 additions and 26 deletions

View File

@@ -35,41 +35,41 @@ Now adding some auth pair.
$ echo first > first
$ _autoenv_authorize first
$ cat $AUTOENV_AUTH_FILE
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:2 (glob)
And a second one.
$ echo second > second
$ _autoenv_authorize second
$ cat $AUTOENV_AUTH_FILE
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:2 (glob)
And a third.
$ echo third > third
$ _autoenv_authorize third
$ cat $AUTOENV_AUTH_FILE
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/third:451243482.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/third:451243482.6:2 (glob)
Re-add the second one, with the same hash.
$ _autoenv_authorize second
$ cat $AUTOENV_AUTH_FILE
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/third:451243482.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/first:2715464726.6:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/third:451243482.6:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:2 (glob)
Re-add the first one, with a new hash.
$ echo one more line >> first
$ _autoenv_authorize first
$ cat $AUTOENV_AUTH_FILE
:/tmp/cramtests-*/_autoenv_utils.t/third:451243482.6:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/first:3620404822.20:1 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/third:451243482.6:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/second:594940475.7:2 (glob)
:/tmp/cramtests-*/_autoenv_utils.t/first:3620404822.20:2 (glob)
}}}