summaryrefslogtreecommitdiff
path: root/bin/common
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-07 16:29:05 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-07 16:29:05 +0200
commitda6de4214938df5e59cc716dc0a336d9da28e9d0 (patch)
tree1b7572056c0465672b40cbb05c1a49a712228626 /bin/common
parent39a11473a452746aaa7a16465a8782fb3b1fbf7b (diff)
checkpoint
Diffstat (limited to 'bin/common')
-rwxr-xr-xbin/common/gt-cmd12
1 files changed, 6 insertions, 6 deletions
diff --git a/bin/common/gt-cmd b/bin/common/gt-cmd
index 74b5f78..8cf30ae 100755
--- a/bin/common/gt-cmd
+++ b/bin/common/gt-cmd
@@ -17,13 +17,13 @@ fi
# Check if repo's remote's key is in ssh-agent
# If key is not registered and command is push/pull we exit with error
+# Note:
+# 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" ]; } &&
- # In my ssh config every Host has the same name as its private key. This means remotes in
- # "$REPOS" (here "$r") + .pub is the public key, so we convert the name to what would be the
- # public key's name and check if its contents are registered in the ssh-agent.
- [ -r "$HOME/.ssh/$r.pub" ] &&
- ! ssh-add -L | grep "$(cat "$HOME/.ssh/$r.pub")" > /dev/null
+if { [ "$command" = "push" ] || [ "$command" = "pull" ] || [ "$command" = "fetch" ]; } &&
+ # key not registered in agent
+ ! { ssh-add -L | grep "$(cat "$HOME/.ssh/$r.pub")" > /dev/null; }
then
printf '%s: '\''%s'\'' not in ssh-agent\n' "$repo_pretty" "$r"
exit 1