0

What are the general steps that I need to follow to generate a local copy of the source (before it actually gets merged) as it would be if a pull request gets merged?

An example situation: suppose, User A forks repo_X (owned by User X) to repo_X_A, does a change to sources src/brittle.c and libs/brittle-lib.c, and raises a github pull request for the repo repo_X. Now, assuming am user X who would want to run some checks on the source before I merge it to repo_X, I want to generate the copies of these sources brittle.c and brittle-lib.c with changes (without actually merging the changes to repo_X). Can I do it programmatically?

Through GitHub APIs (esp the pull req API), I can get the list of modified files for a given pull req. Now, what do I do to generate a local copy of the sources as they would be after applying the changes in pull request?

If am right, I should be getting the diffs in .patch format (through API again), obtain the source from the repo/branch/tag, patch the diff onto it. Need pointers on how to achieve this part of applying the changes in a python program? Using python bindings for *nix patch utility?

Is this indeed the right way, or is there an easier/better/elegant way? Am trying with python-requests and github APIs.

megazoe
  • 545
  • 1
  • 4
  • 17
  • Do you know how to do this from the command line with just Git? Is there a reason why you're trying to create a Python program to do this? –  Aug 05 '13 at 17:53
  • You mean the 'git diff' and 'patch src.c < change.diff' method? Am aware of that. Just that, I was trying to get it done through the python program which is written to analyze the source code; instead of getting these done via CLI. – megazoe Aug 06 '13 at 05:56
  • I don't think any possible way could be more elegant than `git checkout user-a's-branch`. – ptomato Aug 11 '13 at 04:38

0 Answers0