Skip to content

Getting the latest tag of a remote repo #1071

Open
@MTDzi

Description

@MTDzi

The following is from a question on StackOverflow I've asked some time ago:

I'd like to be able to check what's the latest tag for a given repo (I'm using CPython here as an example).

The following works:

g = git.cmd.Git()
blob = g.ls_remote('https://github.com/python/cpython', sort='-v:refname', tags=True)
blob.split('\n')[0].split('/')[-1] 

and yields 'v3.9.0a6' because the blob looks something like this:

'bc1c8af8ef2563802767404c78c8ec6d6a967897\trefs/tags/v3.9.0a6\ndcd4 (...)'

Someone suggested I can contribute this solution to gitpython and someone else suggested that the git ls-remote is pretty stable and well documented so parsing its output might be the right way to go when trying to get the latest tag of a remote repo.

My question: would you like me to contribute this type of functionality? And if so, I'd appreciate a hint on where should it be / how it should be named / anything else.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions