New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyGithub example usage #874
Comments
@sfdye readd the login example please ^^_ |
use repr to display objects
use repr to display objects
This PR add the follow code examples * Issue examples (get list, get specific issue, create issue) * Milestone examples (get list, get specific milestone, create milestone) Ref.: #874
## What does this change do? Adds a small example of how to get at the date a commit took place. ### Changes #### doc/examples/Commit.rst Adds a block of code that demonstrates how to get at a commit's date. ## Motivation This example is in the spirit of #874. When I began using PyGithub it was not readily apparent to me where the commit date was being abstracted to. Being unfamiliar with Git's API, it took some convincing for me to be satisfied that the `Commit.commit.author/committer.date` path would get me the commit date. I would hope that this would save somebody a little bit of time in the future. ## How has this been tested? I've built the docs locally and made sure the HTML is generated as expected. ## Screenshots ![2018-10-11 3](https://user-images.githubusercontent.com/16039329/46782728-add4d980-ccfd-11e8-88dd-1e48be629eb5.png)
I just started with PyGithub, and found some examples, so obviously some work has been done—thanks, people! But I don't see any examples for how to listen for events, e.g. pushevent and pullrequestevent. Could examples for those be added? |
Thanks, @LeviMatus! |
## What does this change do? Adds a small demo implementation of how one might use webhooks to listen for new events in a given repository. ### Additions #### doc/examples/Webhook.rst Adds a new `.rst` file, `Webhook.rst`, which can be used for demonstrating the usage of Webhooks in PyGithub. The example that I've added shows how to continually listen for events using Pyramid in conjunction with PyGithub. ## Motivation This example is in the spirit of #874. [It was asked](#874 (comment)) that someone provide an example of how to listen to events from a repository. ## How has this been tested? I've built the docs locally and made sure the HTML is generated as expected. ## Screenshots ![webhook1](https://user-images.githubusercontent.com/16039329/46991191-40e58900-d0db-11e8-87e4-d5cf2cc18b0a.png) ![webhook2](https://user-images.githubusercontent.com/16039329/46991193-42af4c80-d0db-11e8-9b20-678f70e6baee.png)
In the spirit of PyGithub#874, add some examples for working with Branch objects. It doesn't add everything, but it's a start.
In the spirit of #874, add some examples for working with Branch objects. It doesn't add everything, but it's a start.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hello, I'm a relatively new developer and this is helping a lot. Is any one planning to do examples for github app? Thanks! |
hi! I'm trying to get the content of an specific branch too. Did you get it? Thanks! |
@estagumor If you still need this answer the key is the ref parameter in the
|
@sfdye I just started working with PyGithub and it works great. However even if i'am familiar with the git api, it would be great if you can provide a working example of how to set create / set branch protection rules. I tried for example: |
Yes this did the trick. Unfortunately, require signed commits, is not implemented. Would be nice to have, as it is a policy we need to set on every branch. |
Feel free to send a FR or PR |
#1628 A full example to upload multipe files in one commit |
Hey, I was going through Pull Requests examples, is there any way to get a pull request by its |
This PR add the follow code examples * Issue examples (get list, get specific issue, create issue) * Milestone examples (get list, get specific milestone, create milestone) Ref.: PyGithub#874
## What does this change do? Adds a small example of how to get at the date a commit took place. ### Changes #### doc/examples/Commit.rst Adds a block of code that demonstrates how to get at a commit's date. ## Motivation This example is in the spirit of PyGithub#874. When I began using PyGithub it was not readily apparent to me where the commit date was being abstracted to. Being unfamiliar with Git's API, it took some convincing for me to be satisfied that the `Commit.commit.author/committer.date` path would get me the commit date. I would hope that this would save somebody a little bit of time in the future. ## How has this been tested? I've built the docs locally and made sure the HTML is generated as expected. ## Screenshots ![2018-10-11 3](https://user-images.githubusercontent.com/16039329/46782728-add4d980-ccfd-11e8-88dd-1e48be629eb5.png)
## What does this change do? Adds a small demo implementation of how one might use webhooks to listen for new events in a given repository. ### Additions #### doc/examples/Webhook.rst Adds a new `.rst` file, `Webhook.rst`, which can be used for demonstrating the usage of Webhooks in PyGithub. The example that I've added shows how to continually listen for events using Pyramid in conjunction with PyGithub. ## Motivation This example is in the spirit of PyGithub#874. [It was asked](PyGithub#874 (comment)) that someone provide an example of how to listen to events from a repository. ## How has this been tested? I've built the docs locally and made sure the HTML is generated as expected. ## Screenshots ![webhook1](https://user-images.githubusercontent.com/16039329/46991191-40e58900-d0db-11e8-87e4-d5cf2cc18b0a.png) ![webhook2](https://user-images.githubusercontent.com/16039329/46991193-42af4c80-d0db-11e8-9b20-678f70e6baee.png)
In the spirit of PyGithub#874, add some examples for working with Branch objects. It doesn't add everything, but it's a start.
Thanks a lot for these examples! What I'm missing is an example for exception handling. For instance, it wasn't immediately clear to me how to catch a |
Test show the test result |
@qbits-rwx Following should help with "require signed commit" setting on a branch: https://pygithub.readthedocs.io/en/latest/github_objects/Branch.html#github.Branch.Branch.add_required_signatures |
Hi sfdye, |
How to download a repo ?? |
@VarnaX |
Tentative for a first contribution, as requested by @wangzelin007 on issue PyGithub#874
Motivation:
#862 #456 #321 #584 #762
PyGithub is a great library, however it may not be intuitive to use at the beginning. Not everyone is a Github API expert, so I am trying to provide some working examples (recipes) that will hopefully help you get started.
The skeleton has been setup here and the example docs is already live on readthedocs as usual:
https://pygithub.readthedocs.io/en/latest/examples.html
Note that the list will expand and any PR to add more examples is extremely welcome 😄
If you want to see any examples not covered here, just leave a comment.
The text was updated successfully, but these errors were encountered: