diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-01-11 13:19:52 +0100 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-01-11 13:19:52 +0100 |
commit | 449f969b19e1b6a5e402305f2c968d9ed09dedf7 (patch) | |
tree | e3c963bd18f4d8a27800449e0ec1def2da61d6ee /bin/common/gt-cmd | |
parent | 0467fa38e57589f2bcd5cfeca5643f360800460e (diff) |
checkpoint
Diffstat (limited to 'bin/common/gt-cmd')
-rwxr-xr-x | bin/common/gt-cmd | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/bin/common/gt-cmd b/bin/common/gt-cmd index 8cf30ae..56b8df6 100755 --- a/bin/common/gt-cmd +++ b/bin/common/gt-cmd @@ -21,14 +21,25 @@ fi # path to key: ~/.ssh/<hostname>.pub # where <hostname> is the same in ssh config r="$(grep "$repo" "$REPOS" | cut -f 2 -d ' ' | cut -f 2 -d '@' | cut -f 1 -d ':')" -if { [ "$command" = "push" ] || [ "$command" = "pull" ] || [ "$command" = "fetch" ]; } && - # key not registered in agent - ! { ssh-add -L | grep "$(cat "$HOME/.ssh/$r.pub")" > /dev/null; } +if { [ "$command" = "push" ] || + [ "$command" = "pull" ] || + [ "$command" = "fetch" ]; } then - printf '%s: '\''%s'\'' not in ssh-agent\n' "$repo_pretty" "$r" - exit 1 + Keyfile="$HOME/.ssh/$r.pub" + if [ ! -f "$Keyfile" ] + then + printf '%s: no identity file '\''%s'\''\n' "$repo_pretty" "$Keyfile" + exit 1 + fi + + if ! ssh-add -L | grep "$(cat "$Keyfile")" > /dev/null + then + printf '%s: '\''%s'\'' not in ssh-agent\n' "$repo_pretty" "$r" + exit 1 + fi fi + git -C "$repo" "$command" $args >/dev/null 2>&1 [ $? -gt 0 ] && s="x" || s="o" printf '%s: %s\n' "$repo_pretty" "$s" |