hook special remote: Added combined hook program support.
This commit is contained in:
parent
08c03b2af3
commit
2dce874c77
3 changed files with 68 additions and 22 deletions
|
@ -50,7 +50,7 @@ These environment variables are used to communicate with the hook commands:
|
|||
into 1024 buckets.
|
||||
* `ANNEX_HASH_2` - another hash value, can be used for a second level of hashing
|
||||
|
||||
The setting to use in git config for the hook commands are as follows:
|
||||
The settings to use in git config for the hook commands are as follows:
|
||||
|
||||
* `annex.$hooktype-store-hook` - Command run to store a key in the special remote.
|
||||
`ANNEX_FILE` contains the content to be stored.
|
||||
|
@ -68,3 +68,38 @@ The setting to use in git config for the hook commands are as follows:
|
|||
if and only if the key has been actively verified to be present in the
|
||||
special remote (caching presence information is a very bad idea);
|
||||
all other output to stdout will be ignored.
|
||||
|
||||
## combined hook program
|
||||
|
||||
Rather than setting all of the above hooks, you can write a single
|
||||
program that handles everything, and set a single hook to make it be used.
|
||||
|
||||
# git config annex.demo-hook /usr/local/bin/annexdemo
|
||||
# git annex initremote mydemorepo type=hook hooktype=demo encryption=none
|
||||
|
||||
The program just needs to look at the `ANNEX_ACTION` environment variable
|
||||
to see what it's being asked to do For example:
|
||||
|
||||
[[!format sh """
|
||||
#!/bin/sh
|
||||
set -e
|
||||
case "$ANNEX_ACTION" in
|
||||
store)
|
||||
demo-upload "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY" < "$ANNEX_FILE"
|
||||
;;
|
||||
retrieve)
|
||||
demo-download "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY" > "$ANNEX_FILE"
|
||||
;;
|
||||
remove)
|
||||
demo-nuke "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY"
|
||||
;;
|
||||
checkpresent)
|
||||
if demo-exists "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY"; then
|
||||
echo "$ANNEX_KEY"
|
||||
fi
|
||||
*)
|
||||
echo "unkown ANNEX_ACTION: $ANNEX_ACTION" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
"""]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue