I am trying to update a Python script that checks the status of several local repositories against remote objects from using a subprocess to using GitPython . What is the equivalent command in GitPython for git remote show origin, or the best way to verify that a local repo is advanced or deprecated (etc.)?
$ git remote show origin
* remote origin
Fetch URL: <url>
Push URL: <url>
HEAD branch: master
Remote branches:
XYZ tracked
master tracked
Local branches configured for 'git pull':
XYZ merges with remote XYZ
master merges with remote master
Local refs configured for 'git push':
XYZ pushes to XYZ (up to date)
master pushes to master (up to date)
The last two lines are my main problem. It seems like this is possible with GitPython , iterating over git.Repo.headsand git.Repo.remotes.origin.refsand comparing hashes .master.commit(etc.). This seems to be much bigger than the single git command above, and will require even more work to indicate which side is out of date. I was expecting something like git.Repo.remotes.origin.status(). What is the correct way to define this in GitPython ?
source
share