1

Found this answer to help with gitPython and ssh keys GitPython and SSH Keys?

I want to dynamically use the latest tagged version for something, but without cloning the repo.. something like

import os
from git import Repo
from git import Git

git_ssh_identity_file = os.path.expanduser('~/.ssh/id_rsa')
git_ssh_cmd = 'ssh -i %s' % git_ssh_identity_file

with Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
    repo = Git('git@<cdn>')
    # repo = Repo('git@<cdn>') # this doesn't work, gives a 'NoSuchPathError'

latest_tag = # how to get tags?
<do something with latest_tag>

I'm unable to find any examples and my git python knowledge is very small

Mitch Wilson
  • 109
  • 10
  • 1
    "*`Repo('git@')` doesn't work, gives a 'NoSuchPathError'*" You cannot open a remote repository, GitPython works only with local repos. – phd Aug 25 '20 at 18:40
  • @phd welp that answers that. Thanks! – Mitch Wilson Aug 25 '20 at 20:51
  • Is there a way to accomplish what I'm wanting to do? – Mitch Wilson Aug 25 '20 at 20:51
  • https://stackoverflow.com/q/21439488/7976758 Something like `git ls-remote --tags` See https://stackoverflow.com/search?q=%5Bgit%5D+find+latest+tag+remote+repository – phd Aug 25 '20 at 22:00
  • https://stackoverflow.com/a/35585837/7976758 `git ls-remote` in GitPython is `git.cmd.Git().ls_remote(url)` [gitpython] "ls-remote" – phd Aug 25 '20 at 22:02

0 Answers0