From a900e2d74258a386909c78d9c688438eea713437 Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Nov 15 2017 19:16:26 +0000 Subject: bin/get_formulas.py: use ssh-agent when fetching remotes if needed when the remote's URL is via ssh, we need to use our ssh keypair from the running ssh-agent in order to fetch it --- diff --git a/bin/get_formulas.py b/bin/get_formulas.py index d768cb8..a7ba387 100755 --- a/bin/get_formulas.py +++ b/bin/get_formulas.py @@ -73,9 +73,15 @@ def create_symlinks(DEST): def fetch_remote(remote, formula): from pygit2.errors import GitError + import pygit2 + remotecallbacks = None + if not remote.url.startswith(('http://', 'https://', 'git://', 'ssh://', 'git+ssh://')): + username = remote.url.split('@')[0] + credentials = pygit2.KeypairFromAgent(username) + remotecallbacks = pygit2.RemoteCallbacks(credentials=credentials) try: - remote.fetch() + remote.fetch(callbacks=remotecallbacks) except GitError: print('%s-formula: Failed to fetch remote %s' % (formula, remote.name))