feat(git): configure age textconv

This commit is contained in:
Peter 2024-02-07 07:52:48 +01:00
parent ddae1cfb1e
commit 7055986bb2
Signed by: prskr
GPG key ID: F56BED6903BC5E37
2 changed files with 34 additions and 34 deletions

View file

@ -59,3 +59,6 @@
clean = git-age clean -- %f clean = git-age clean -- %f
smudge = git-age smudge -- %f smudge = git-age smudge -- %f
required = true required = true
[diff "age"]
textconv = cat

View file

@ -1,5 +1,5 @@
#!/opt/homebrew/Cellar/bash/5.2.21/bin/bash #!/usr/bin/env bash
#
# rbw git-credential helper # rbw git-credential helper
# Based on https://github.com/lastpass/lastpass-cli/blob/master/contrib/examples/git-credential-lastpass # Based on https://github.com/lastpass/lastpass-cli/blob/master/contrib/examples/git-credential-lastpass
@ -9,39 +9,36 @@
# 1. Put this somewhere in your path. # 1. Put this somewhere in your path.
# 2. git config --global credential.helper rbw # 2. git config --global credential.helper rbw
declare -A params set -f
if [ "x$1" == "xget" ]; then [ "$1" = get ] || exit
read line
while [ -n "$line" ]; do while read -r line; do
key=${line%%=*} case $line in
value=${line#*=} protocol=*)
params[$key]=$value protocol=${line#*=} ;;
read line host=*)
host=${line#*=} ;;
username=*)
user=${line#*=} ;;
esac
done done
if [ "x${params['protocol']}" != "xhttps" ]; then output=
exit #shellcheck disable=2154
fi for arg in \
"${protocol:+$protocol://}$host" \
"$host" \
"${host2=${host%.*}}" \
"${host2#*.}"
do
# exit on first good result
[ -n "$user" ] && output=$(rbw get --full "$arg" "$user") && break
output=$(rbw get --full "$arg") && break
done || exit
if [ -z "${params["host"]}" ]; then printf '%s\n' "$output" | sed -n '
exit 1{ s/^/password=/p }
fi s/^Username: /username=/p
s/^URI: /host=/p
rbw ls > /dev/null 2>&1 '
if [ $? -ne 0 ]; then
echo "Please login to rbw to use git credential helper" > /dev/stderr
exit
fi
user=`rbw get --full ${params["host"]} | grep "Username:" | cut -d' ' -f2-`
pass=`rbw get ${params["host"]}`
if [ "x$user" == "x" ] || [ "x$pass" == "x" ]; then
echo "Couldn't find host in rbw DB." > /dev/stderr
exit
fi
echo username=$user
echo password=$pass
fi