-
-
Notifications
You must be signed in to change notification settings - Fork 599
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
Allow getting repo info by id, not just user and repo name #579
Conversation
lib/Github/Api/Repo.php
Outdated
/** | ||
* Get extended information about a repository by its id. | ||
* | ||
* @link http://developer.github.com/v3/repos/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a note saying it isn't documented...
@violuke This is awesome! I normally have to parse repo full_name to use the API... |
@m1guelpf Yes, added test and good thinking to note that it's undocumented in the code, that's done! |
doc/repos.md
Outdated
@@ -48,6 +48,12 @@ $repos = $client->api('repo')->find('chess', array('language' => 'php', 'start_p | |||
$repo = $client->api('repo')->show('KnpLabs', 'php-github-api') | |||
``` | |||
|
|||
or | |||
|
|||
```php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add the note about the undocumented feature also here in the docs. This makes it more visible for users using this api method. We can remove the note later when it's official mentioned in the docs!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, I really like this PR. Just had a minor comment.
*/ | ||
public function showById($id) | ||
{ | ||
return $this->get('/repositories/'.rawurlencode($id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the ID always an integer? Why do we ned rawurlencode?
´return $this->get(sprintf('/repositories/%d', $id));`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should always be an integer (currently anyway). I thought about checking that they'd input an integer and if not throwing an exception, but then figured that it was better than us assuming IDs never become non-integers to just pass it over to GitHub and let them respond accordingly. Having the rawurlencode
ensures that whatever is passed into the function (even if it shouldn't have been) is sent over to GitHub properly.
There probably isn't much in it as I think it's highly unlikely that GH will ever start to issue non-integer IDs, but personally I prefer this way - it's GitHub's ID, let's let them validate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this feature. |
@Nyholm Do you follow semver? |
Of course. Why? |
@Nyholm Could you release a patch version with this functionality? |
I guess it will be a minor release as this is a new api method? |
No we cant. This is a new feature. That means that we have todo a minor release. I added a milestone for the next release. See https://github.com/KnpLabs/php-github-api/milestone/4. |
This PR was squashed before being merged into the 2.x branch. Discussion ---------- Revamp of #372 which was abandonned, and following the example of #579 As of 2020, gettting data by ID is still undocumented. I contacted Github support to make sure it could be relied on. > <img width="691" alt="Screen Shot 2020-07-02 at 10 12 15 PM" src="https://user-images.githubusercontent.com/664857/86434021-2d17f700-bcb1-11ea-9f19-2008ce47412d.png"> ------ I have been working with an old application and I have to deal with actions made by user that have changed their login since. The old login are now used by totally different people, which can be problematic. Commits ------- 5ed46cc Update User.php 5703492 Add unit test 62b43ab Documentation cdaad05 Remove usage of rawurlencode
Is this still undocumented? |
This is an undocumented feature, but GitHub support have said it can be relied on. It's also really handy!
GitHub support said:
See piotrmurach/github#283 and piotrmurach/github#282