YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.22k stars 403 forks source link

Cannot use slashes in branch name #409

Open dagmanolis opened 3 years ago

dagmanolis commented 3 years ago

Hello, I am using bitbucket repo. If I use $myUpdateChecker->setBranch("impl/default") it doesnt recognize the branch. This is cache from debug bar

Puc_v4p10_Plugin_Update Object
(
    [id] => 0
    [homepage] => https://domain/
    [upgrade_notice] => 
    [tested] => 
    [requires_php] => 
    [icons] => Array
        (
        )

    [filename] => plugin_name/plugin_name.php
    [slug] => plugin_slug
    [version] => 
    [download_url] => https://bitbucket.org/abc/xyz/get/impl/default.zip
    [translations] => Array
        (
        )

)

Anyone else have this problem?

YahnisElsts commented 3 years ago

It looks like at least the download URL is pointing to the branch. Is that correct? In that case, is the problem that the rest of the update information is not populated (for example, the "version" property is empty)?

I would recommend installing the Debug Bar plugin. Then you can go to the "PUC (plugin-slug)" panel and click "Request Info", which should show any BitBucket API errors that the update checker encountered while trying to retrieve plugin details.

dagmanolis commented 3 years ago

Yes , the download link is correct. I don'use tags. I am using Debug Bar, but the request info button doesn't do anything

YahnisElsts commented 3 years ago

I've done some testing of my own and it looks like the BitBucket API doesn't handle branch names with slashes very well. I created a branch with a slash in one of my test repositories. If I give the API the branch name as-is, I get a 404 Not Found error. If I URL-encode the name, I get a 401 Unauthorized error instead even though I'm using the same authentication details as before (unless it's a bug in my OAuth implementation?).

Perhaps it's better to use the commit hash if one is available. I've committed a patch that does this. Please give it a try.

dagmanolis commented 3 years ago

Thank you. I will try that in my next version.

dagmanolis commented 3 years ago

By the way, your plugin is awesome. Thank very much for sharing this.

YahnisElsts commented 3 years ago

Sure, no problem. I'll leave the issue open for now. If the patch works for you, please leave a note here later.