-
-
Notifications
You must be signed in to change notification settings - Fork 964
Description
Bit of a n00b question so apologies in advance.
I am trying to write a little script that,
pullthe repo- Check if that
pullincluded any changes - If there have been changes, restart a target program
I have found several ways of checking for changes but none seem to work. Each time, I tested by making a change in my sandbox repo directly on GitHub and then executed the pull, so that the change is applied on my PC. For example,
changed_files = [item.a_path for item in repo.index.diff(None)]
Always appears to output an empty list. This seems to be what the tutorial suggests so I'm not sure why it does not work.
current = repo.head.commit
if current == repo.head.commit:
print("Repo not changed. Sleep mode activated.")
return 0
else:
print("Repo changed! Activated.")
return 1
Always returns 0.
diff = repo.git.diff(repo.head.commit.tree)
print(diff)
When I checked the output when there was a change vs the output where there was no change, both outputs were the same.
What am I doing wrong here?
I have also found a SO question that was asked some time ago but never answered, so I'm not alone in this! Comments in that suggested git diff however I think I have tried that with the first method.
What is the best way to check if a pull has introduced changes since the last pull?