2

I'm trying to write a script that will be triggered by a pull request github webhook. When this script is triggered, it needs to find out which files were modified from master to newBranch. End of day, I'll read through those files, verify that no breaking changes were made, and then write up why it should/shouldn't be merged and send it off to a human to confirm.

I'm using gitpython (or, rather, trying to), but the documentation doesn't really go over the PR use case.

My code looks like this so far, but I'm not convinced that I'm doing things correctly:

repo = git.Repo('.')
repo.config_reader()
for d in repo.index.diff(repo.remotes.origin.refs.master.commit):
 print d
 print d.diff

I guess I'm not sure what the index is in a PR, so I'm not convinced that this is diffing the right things. When I try it out in a test repo, I don't see any diffs unless I'm manually fixing merge conflicts, so I suspect I'm not doing things correctly.

Can you please either help me with the code, or suggest a workflow that I could use to test this script? I'm getting all muddled up the more I look at this.

asked Nov 16, 2016 at 18:33

1 Answer 1

2

This is not the right approach.

PRs are not a git concept; they are a Github one. You can't use gitpython for this. You will have to use Github's own API, for which there are several third-party libraries.

answered Nov 16, 2016 at 18:45
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.