Skip to content

Commit

Permalink
Update pygithub_method.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbain committed Feb 17, 2016
1 parent 59049e1 commit 6657a18
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions pygithub_method.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
Here is a workflow for forking, then creating a pull request from within python. Requires PyGitHub
```
Here is a workflow making use of [pygithub](https://github.com/PyGitHub/PyGithub.git)

1) Create new repo:

```python
from github import Github
g = Github(user,pass)
u = g.get_user()
g = Github(user,pass) #or, g=Github(token) where token is personal Oauth token
u= g.get_user()
u.create_repo('new_repo')
```

or, to Fork an existing repo

```python
other_repo = g.get_repo('cclauss/GitHub-web-plus-app-workflow')
mine = other_repo.fork()
# now modify something
other_repo.create_pull(title='test pull, feel free to ignore',body='Here is an alternate method, using pygithub', base='master',head='jsbain:master')
mine=u.fork_repo(other_repo)
```

Create a pull request (after using stash to push to your own github)
```python
# call create_pull on the repo you want to pull INTO. base = name of branch in that repo. head = name of YOUR repo, as user:branch
other_repo.create_pull(title='A web-free example, using only python',
body='here is a simple example using pygithub to fork a repo, then create a pull request',
base='master',
head='jsbain:master')
```

0 comments on commit 6657a18

Please sign in to comment.