The Branch protection API has been radically changed by GitHub, add new
methods to Branch reflecting it. Branch protection methods are now
called on the Branch object itself, rather than awkwardly hanging off
the Repository object and requiring branch names to be passed in.
This adds an over-arching methods to get, edit and remove protection
entirely, as well as fine-grained methods for getting, setting and
dropping certain aspects of branch protection, as well as three new
objects to encompass querying those aspects.
This also destroys Repository.protect_branch(), the endpoint has been
removed. The old-style protection attributes on Branch have also been
removed to force users onto the new API, since they are still sent, but
no longer populated.
Fixes#586
Closes#784Closes#785
First commit fixes a small bug that I observed while trying to record some new test fixtures: the stringification of the headers is not correctly printed as a list of tuples, but as an `iteritems` object, so I forced the list evaluation.
Second commit adds the missing properties `allow_merge_commit`, `allow_rebase_merge`, `allow_squash_merge`, and `has_projects` to the `Repository` class.
Note however that I ran into some trouble while modifying the `edit` method of the `Repository` class to make use of the new properties, specifically while writing tests, so I will fix the `edit` method in a future PR.
Fixes ##840
Adding archival support to Repository.edit
No unit tests are included for this change because while you can archive a repository via the edit API, there is no way to un-archive a repository via the edit API. (See: https://developer.github.com/v3/repos/#edit )
As mentioned in https://developer.github.com/v3/orgs/, an organization also has a description. This PR adds this attribute to the `Organization` class, as well as modifies its `edit` method so that it's possible to update it.
I noticed too late the [`add_attribute.py` script](https://github.com/PyGithub/PyGithub/blob/8ae2bcb1e6f96beeec99fbbcf00f4af46bb38cde/scripts/add_attribute.py), so I did my modifications by hand, but I noticed that the output of the script and the style used for all the other attributes are different. I preferred the style that is prevalent in the file, rather than the output of the script.
This PR #596 seems stale, so I have opened up this one with the requested changes from @sfdye.
This is the code from @Tommos0's [comment][1] with some modification.
There are 2 tests failing. I think this is due to the change in the query string and the cached test data just needs to be refreshed for those tests.
[1]: https://github.com/PyGithub/PyGithub/pull/596#issuecomment-315013949
Hi!
As part of my app, I use this lib, and then your test Framework to record my own upper level tests. Here's some patches I had to make that I humbly think could interest you:
- As stated by @kyogi14 in [this comment](https://github.com/PyGithub/PyGithub/pull/664#issuecomment-389964369), since you use `requests` recording is broken. This fixes that.
- Fix some Python 3 troubles while recording
- Add a `replayDataFolder` gloval class variable, to override the default place to put the recording. Otherwise, if a third party app (like mine :)) has a dependency on PyGithub and wants to use the Framework, recordings are saved in `site-packages/github/tests/ReplayData` instead of my own place.
Hope this helps, please let me know if I can improve the PR.
Thanks!
* Handle HTTP 202
Fixes#564
After some testing, it seems GitHub seems to be able to process the chrunching of statistics
for every repository I tested in around 2 seconds. So a delay of around 5 seconds should be
plenty to be very certain that the next try should succeed.
Another option would be to put this value lower and possibly waste an extra retry on it.
* Only re-request data if HEAD or GET (those are 'safe')
to e.g. avoid running a duplicate POST or PUT, that can change stuff on the server
Using RFC 2616 and https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html as guideline
* Fix testStatistics
* change wait time to 2 secs
In the old code the self.__hostname would be overwritten with uploads.github.com
but it could not be correctly re-set to api.github.com after completing the upload
Create a separate connection if hostname or port differ in requestBlobAndCheck
in the end this became quite a large overhaul, to also make this change generic
for e.g. connecting to status.github.com and similar methods
~~not sure if tests need (more) updating, if so I will update the PR accordingly~~
Hi, here's my small contribution to the documentation in relation to #819
Few things:
* the `delete_release` method always returns `True` so not sure if the return type is truly valid - potentially a bug
* I've tried generating the documentation locally to check if formatting is ok but failed - is there a guide to it? I followed the read the docs starter guide but that didn't seem to reflect the way it's done here
Per the Github v3 API [docs](https://developer.github.com/v3/teams/members/#deprecation-notice-2), the "remove team member" api is deprecated. This PR implements the new API call.
Deprecated API:
```
DELETE /teams/:team_id/members/:username
```
New API:
```
DELETE /teams/:team_id/memberships/:username
```
This PR also adds a `deprecation` notice to the docstring of the deprecated methods.
The API docs for Repository.get_git_tree specify that the URL parameter
for fetching a tree recursively should be ?recursive=1, not a truthy
value. To not change the API we present, check if it is True before
setting it to 1. Change another callsite of Repository.get_git_tree to
specify recursive=False to make sure it doesn't appear in the query
string.
Fixes#560
Add create_review_request() and delete_review_request() methods to
PullRequest, as well as renaming get_reviewer_requests() to
get_review_requests() and cleaning up its return value to firstly respect
teams, and secondly to cut out the middleman of PullRequestReviewerRequests,
which has been removed.
Fixes#597
Clean up some of the issue methods in PullRequest to make use of the
issue_url property, rather than chopping pieces off the URL to replace
/pulls/ with /issues/.
* works (but tests fail)
* Refactor to use python requests rather than httplib
* add requests dependency in setup.py
* touch so travis-ci will run
* clean up some unused comments
* Handle HTTP vs HTTPS; handle custom base_url
* Use requests session
* Don't use a persistent session in tests (which don't use the real requests library)
* Use an older version of requests for python 3.2
Requests dropped support for Python 3.2 in the 2.10 series (though it
didn't detect this until 2.11).
PyGithub probably doesn't need to support Python 3.2 at all; it's quite
old, with negligably few users, but that should be addressed elsewhere.
* Revert "Use an older version of requests for python 3.2"
This reverts commit fb0367614f5413968eeab98f4094e710aa1bc2d1.
* Improve readability
* Update requirements.txt
* Disable custom proxy handling code (unneeded and broken); use requests'
* Remove comment and superflous code
* Fix iteritems() removal from Python3
* pin requests to 2.14.0 or greater in prep for no_proxy
* pin requests to 2.14.0 or greater in prep for no_proxy
The Github API docs for PullRequests say to make use of the Issues API
to add, remove, set and query labels. This means that we need to make
use of the issue_url property for the PullRequest, not its own URL.
PullRequests can also have labels attached to them, like Issues or
Milestones. Extend PullRequest to also export them if they are present,
as well as adding methods to add, remove and set labels.
* Add methods add_to_members(), has_in_pending_members(), and remove_from_membership() methods to Organization class.
* Add scrubbed replay files used for testing
* More massaging of test data
* Fix URL to remove organization membership
* Remove `has_in_pending_members()` method
* Add team privacy and add additional parameter to test. Still requires replaydata
* Reorder parameters to not break existing code
* Update tests for #702
The description attribute handling requirement is
a custom media type in the Accept header:
application/vnd.github.symmetra-preview+json
Limitation: Repository.get_labels does not report description,
possibly something has changed in the preview API.