import git # gitpython module
def update_repo(repo)
repo = git.Repo(repo)
ret = repo.remotes.origin.pull()
print(ret)
# some code I want to execute if and only if repo.remotes.origin.pull() changed something within the directory
update_repo('/Path/To/Repo/.git')
>>> [<git.remote.FetchInfo object at 0x7f83521b21b0>]
I tried printing what repo.remotes.origin.pull()
returns and got a list of git.remote.FetchInfo
object. I searched it up, and found a reference of this in their documentation git.remote.FetchInfo but I quite don't understand if anything in there would help me with what I want to achieve.
While reading the documentation over and over again, I finally realized that git.remote.FetchInfo.flags
gave me an integer depending on the action of the pull
after a bit testing, I found out that if the flag == 4
then no files whereas flag == 64
means that there was a change
def update_repo(repo)
repo = git.Repo(repo)
ret = repo.remotes.origin.pull()
print(ret)
if ret[0].flags == 4:
return
# rest of the code I wanted to execute only if a change took place