leewillis77 / wp-github-oembed

WordPress Github "oEmbed" plugin
GNU General Public License v2.0
69 stars 19 forks source link

Adding release information #17

Closed f13dev closed 5 years ago

f13dev commented 8 years ago

I have added two new functions to the API Class

The first is "public function get_repo_releases ( $owner, $repository )" which retrieves the response of "https://api.github.com/repos/$owner/$repo/releases" to determine if the specified repo has any releases.

The second is "public function get_repo_releases_latest ( $owner, $repository )" which retrieves the response of "https://api.github.com/repos/$owner/$repo/releases/latest" to gain access to the html_url and tag_name attributes.

Finally I have included code to "private function oembed_github_repo ( $owner, $repository )" to check if any releases exist, and if so to include a link to the latest release.

If no releases are available "Latest release: none" is displayed above forks. If one or more releases exist "Latest release: " is displayed above forks, where is the version of the latest release, which is surround by an anchor tag linking to the latest release page on Github.

Jim Valentine

screen shot 2016-06-23 at 10 27 27
leewillis77 commented 8 years ago

Hi;

Thanks for the PR. I'll take a look over the next few days and come back if I have any questions!

leewillis77 commented 8 years ago

Hi;

Thanks again for the PR. I've taken a look at this and while I can't see any issues with the code, due to the the way GitHub works it actually produces some fairly confusing / misleading results that make me think that I wouldn't want to include it.

Take this repo for example: https://github.com/leewillis77/wp-github-oembed

If you visit the "releases" page on github.com (https://github.com/leewillis77/wp-github-oembed/releases) then you'll see five different releases. These have all been generated from tags on the repo rather than specifically being "released" through GitHub. I imagine that this is a pretty common scenario.

If you look at the results produced by your changes though, it will happily output that there isn't a release as the GitHub API doesn't include tag-only releases in the releases endpoint, e.g. the following API endpoint returns an empty array: https://api.github.com/repos/leewillis77/wp-github-oembed/releases

So - I think for most people this is going to produce confusing output?

https://www.dropbox.com/s/3kvrvg72gd1vdh2/Screenshot%202016-07-01%2010.44.15.png?dl=0

f13dev commented 8 years ago

Hi Lee,

Thank you for the feedback, that would cause an issue as anybody using the plugin would want the latest version displayed whether it's via GitHubs release or via tags, with the worst case being a project advertised as having no release which would discourage clicks.

I will have a look and see if I can work a way of searching for the latest release via GitHubs release and via tags and will send a new PR if I can find a suitable method of doing so.

Many thanks Jim

leewillis77 commented 8 years ago

👍