Commit Graph
925 Commits
Author SHA1 Message Date
AetherDeity ee9f098d91 Add a trailing slash to URL when updating or deleting a file (tests fixed) (#931)
* Add a trailing slash to URL when updating or deleting a file.

* Update test files to match new create/update/delete_file Repo methods

* Add trailing slash to get_contents() method

* update tests

* add missing slash in get_dir_contents

* add example usage

* remove dup slashes in tests

* clarify example comments
2018-10-17 08:21:17 +08:00
Wan Liuyang ade78ffb2d Fix test 2018-10-10 16:43:02 +08:00
h.shi 1fa25670f7 Add highlight search to search_code function (#925)
*  add highlight search to search_code function

*  add highlighting search code tests
2018-10-10 16:38:47 +08:00
Riccardo Pittau c13b43ea9c adding suspended_at property to NamedUSer (#922) 2018-10-08 21:26:38 +08:00
Michell Stuttgart 562908cb17 Improve __repr__ method of Milestone class (#921)
This commit add the title of milestone in string representation of Milestone class.
This modification improve readbility of milestone instances.

Before:
```python
>>> repo.get_milestone(number=1)
Milestone(number=1) 
```
After:
```python
>>> repo.get_milestone(number=1)
Milestone(title='Milestone Example', number=1) 
```
2018-10-08 10:19:38 +08:00
Steve Kowalik 6833245d99 Fix handling of 301 redirects (#916)
Requester.__requestRaw() was handling 301 redirects by passing the full
URL to itself, when it only expects a URL path, so parse out the path,
and pass that in. Add a test for this behaviour.

Closes: #906
2018-10-04 21:41:17 +08:00
Riccardo Pittau c411196f24 get repos missing params for authenticated users (#915)
first commit to fix issue #435
2018-10-04 15:55:11 +08:00
Bruce Richardson e18b107883 Gists with since (#914)
The Github gists api has a since parameter for the various gist searches.  This adds that parameter to Github.get_gists(), NamedUser.get_gists() and Authenticator.get_gists().  Tests and replay data added/updated as needed.

I added a Time module in the tests directory, containing just a UTCtzinfo class, which I felt I needed for one of the tests (and would probably be useful in other since/until tests).  Might not be the best name for the module but it seemed the least invasive thing to do.
2018-10-03 11:51:59 +08:00
Brian J. Murrell a18eeb3a05 Line comments are not posted in create_review() (#909)
When create_review() is called with comments in the comments argument,
they are not actually posted in the API call.
2018-09-26 09:55:33 +08:00
Wan Liuyang 598bee8193 Fix totalCount for empty response, closes #905 2018-09-18 16:34:38 +08:00
Jacopo Notarstefano 7286eec0e0 Fix Repository.edit (#904)
Allows to pass falsy values to the new arguments introduced in #844.

Closes #903
2018-09-16 20:00:20 +08:00
Wan Liuyang d92389be07 Restore RateLimit.rate attribute, raise deprecation warning instead 2018-09-12 14:53:44 +08:00
Yossarian King faca4ce1c0 Add support for projects (#854)
Initial solution for [PyGithub support for projects](https://github.com/PyGithub/PyGithub/issues/606) (#606). Adds comprehensive project querying API.

Currently does not support for modifying projects, columns or cards. (I only need this interface for reporting purposes. Of course once I'm done others are more than welcome to add additional features!)

API that was integrated:
https://developer.github.com/v3/projects
https://developer.github.com/v3/projects/columns
https://developer.github.com/v3/projects/cards

Note that the Github project API is in preview mode - it requires a special header in order for requests to be processed, and the API is subject to change without notice.

## Summary
- new classes: Project, ProjectColumn, ProjectCard
- add Organization.get_projects method
- add Repository.get_projects method
- add MainClass.get_project method
- add test cases to exercise all new classes and methods and verify attributes are as expected; replay data is included, recorded (mostly) from my fork of PyGithub
- updated add_attribute script to:
  - use makeXXXAttribute API
  - be able to add to the end of the current set of properties
  - handle both Completable and NonCompletable class types correctly

## Checklist
Not to be merged until these are done:

- [x] remaining Project properties
- [x] remaining ProjectColumn properties
- [x] remaining ProjectCard properties
- [x] support for archived_state parameter when getting cards: all,archived, or not_archived
- [x] get issue from card, not just pull request ("get_content" method?)
- [x] centralize header management for "preview" access to projects API
- [x] add test for retrieving organization projects
- [x] add test for getting issue / pull request content from card
2018-09-11 13:05:16 +08:00
Shubham Singh 3ce0418382 Feature: Search By Topics (#893) 2018-09-06 11:44:53 +08:00
Wan Liuyang fd8a03648a Adding support for search/graphql rate limit, fixes #553 2018-09-05 12:33:20 +08:00
Steve Kowalik 55b8fb4ca1 Add missing backticks to Branch Protection docs (#889)
The docstrings for the Branch Protection methods that take classes as
arguments were missing backticks for the class name, add them so the
docs contain proper links.
2018-08-28 16:10:22 +08:00
Steve Kowalik eb80564b01 Implement Organization.invite_user (#880)
Utilize the API preview for the organization invite system to allow
organization owners to invite outside colloborators either via passing
in the user directly, or their email address.
    
Fixes #851
2018-08-28 14:29:23 +08:00
Steve Kowalik ef16702a0d Add support for required approving review count (#888)
The GitHub API currently has a beta extension to the Branch Protection
API that allows inspection and setting of the number of required
approving reviews required for a PR to be merged. Add support for it.
2018-08-28 13:34:34 +08:00
Steve Kowalik 08fa797f1d Improve Branch Protection function docstrings (#887)
The docstrings for the edit methods for portions of Branch Protection
did not document their arguments and types, add them.
2018-08-28 13:12:33 +08:00
Steve Kowalik 7b099c9800 Implement Repository.get_collaborator_permission (#881)
Add a method to Repository, collaborator_permission that allows users
with push access to repositories to query the permission level of
collaborators.

Fixes #722
2018-08-27 13:23:03 +08:00
Steve Kowalik 6732517c1d Change MainClass.get_repo default laziness (#882)
MainClass.get_repo() used to default to lazy fetching, which is not what
NamedUser.get_repo() does, so change the default. Fix the tess to pass
lazy=True, so that we don't need to grow 8 ReplayData files with 11
lines of the repository in question.

Fixes #353
2018-08-27 11:57:58 +08:00
Aaron L. Levine 7ac2a2ac97 Adding new attributes to IssueEvent (#857)
See Issue #855 

The class [IssueEvent](https://github.com/PyGithub/PyGithub/blob/master/github/IssueEvent.py) is missing a large number of attributes documented in the [API](https://developer.github.com/v3/issues/events/).

This is also commented about in #653 to a degree

27 of the tests 27 known event types have tests.

**Currently Tested using Issue #30**            
- [x] subscribed
- [x] assigned
- [x] referenced               
- [x] closed                   
- [x] labeled                  

**Currently Tested using Issue/PR #538**
- [x] merged
- [x] mentioned
- [x] review_requested

**Currently Tested using Issue/PR #857**
- [x] reopened
- [x] unassigned
- [x] unlabeled
- [x] renamed
- [x] base_ref_changed
- [x] head_ref_deleted 
- [x] head_ref_restored
- [x] milestoned
- [x] demilestoned
- [x] locked
- [x] unlocked
- [x] review_dismissed
- [x] review_request_removed
- [x] marked_as_duplicate
- [x] unmarked_as_duplicate
- [x] added_to_project       
- [x] moved_columns_in_project
- [x] removed_from_project
- [x] converted_note_to_issue - Note: this event is tied into Issue #866 

This PR is now ready to be merged
2018-08-25 00:01:29 +08:00
Wan Liuyang de6b713b05 Force absolute import, fixes #314 2018-08-24 15:08:18 +08:00
Steve Kowalik 3cc0742fbe Switch remaining try/except tests to assertRaises (#879)
The BadAttributes and Enterprise tests made use of try/except to check
details of raised exceptions, so switch to using assertRaises, much like
the github.GithubException tests[1].

1: cf05688359
2018-08-24 10:52:53 +08:00
Wan Liuyang f3abadae08 Fix Organization display name 2018-08-21 15:29:36 +08:00
Wan Liuyang 7c73d8de4e Fix Organization display name 2018-08-21 15:25:56 +08:00
Wan Liuyang ae5cdb285e Refactor common header constants and custom media type 2018-08-21 15:01:23 +08:00
Steve Kowalik ebcd3a52e3 Remove custom swamp-thing-preview header (#873)
The Repository Invitation API graduated on July 17, 2017, so the custom
Accept header is no longer required.
2018-08-21 13:49:04 +08:00
Steve Kowalik 49db6f8771 Remove Repository.get_protected_branch (#871)
With both the custom Accept header and the new code that supports the
new Branch Protection API, Repository.get_protected_branch() is no
longer required, and it also was never tested, so remove it.
2018-08-20 17:25:32 +08:00
Wan Liuyang 310d0733ee Fix a few docs error 2018-08-20 16:07:36 +08:00
Wan Liuyang 3f0caa4057 Sync copyright header 2018-08-19 10:47:41 +08:00
Dylan 43d325a552 Add allow_redirects option (#858)
Fixes #830

Latest release v1.40 has broken get_archive_link
https://github.com/PyGithub/PyGithub/issues/830
2018-08-19 10:41:32 +08:00
e1df09f7a6 Fix a bug cause gistfile.content None. (#486)
Fixes #485 

See issue: https://github.com/PyGithub/PyGithub/issues/485
2018-08-15 15:14:24 +08:00
Steve Kowalik cf05688359 Use TestCase.assertRaises() (#782)
Now that we no longer support Python 2.6, we can use the assertRaises()
method of TestCase as a context manager, tiding up a large amount of
technical debt.
2018-08-15 14:54:57 +08:00
Steve Kowalik b91dee8df6 Revert "Remove NamedUser.contributions (#774)" (#865)
This reverts commit a519e4675a.

NamedUser.contributions can be populated, so we should fill in the data.

Fixes #850
2018-08-15 11:39:08 +08:00
Steve Kowalik 171cc567ae Update Branch Protection to current GitHub API
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
2018-08-15 12:45:47 +10:00
Jacopo Notarstefano 29d231517d Add missing arguments to Repository.edit (#844)
As promised in https://github.com/PyGithub/PyGithub/pull/842, here's a PR to update the `edit` method so that it allows editing the newly added properties.
2018-07-15 10:32:53 +08:00
Jacopo Notarstefano 2b352fb397 Add missing properties to Repository (#842)
Closes #784
Closes #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.
2018-07-13 12:02:53 +08:00
sechastain 1a90f5db5d Adding archival support for Repository.edit (#843)
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 )
2018-07-12 11:17:51 +08:00
nurupo 790f7daeb8 Add tag_name and target_commitish arguments to GitRelease.update_release (#834)
Fixes #833
2018-07-10 22:58:08 +08:00
Jacopo Notarstefano c00217472b Allow editing of Team descriptions (#839)
PR https://github.com/PyGithub/PyGithub/pull/753 added this property but forgot to make it editable. The current PR fixes this omission.
2018-07-10 21:35:00 +08:00
Jacopo Notarstefano 1d91880967 Add description to Organizations (#838)
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.
2018-07-10 15:04:29 +08:00
Wan Liuyang 8a589c9d73 Revert __len__ for PaginatedList to fix the tests, will revisit later 2018-07-10 10:36:30 +08:00
sfdye 8ae2bcb1e6 Implement __len__ for PaginatedList, fixes #579, closes #433 2018-07-08 11:40:17 +08:00
Joel Koglin e6eabe9ad0 Calcuate totalCount without iterating PaginatedList (#820)
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
2018-07-08 10:43:48 +08:00
Will Yardley c6802b515f Add support for getting / replacing topics (#634) (#832)
* Add support for getting and replacing topics on a repository #634

* Add / fix tests, accept list vs dict for replace_topics (#634)
2018-07-06 11:09:10 +08:00
Laurent Mazuel faa8f20570 Test Framework improvement (#795)
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!
2018-06-23 11:29:09 +08:00
Maarten Fonville 3aead15818 Handle HTTP 202 HEAD&GET with a retry (#791)
* 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
2018-06-22 16:54:32 +08:00
Maarten Fonville 8bdac23ca1 Fix github API requests after asset upload (#771)
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~~
2018-06-22 12:46:46 +08:00
Kuba e389396405 GitRelease methods documentation (#821)
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
2018-06-20 10:39:06 +08:00