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

Incorrect project id in GitLab URLs #427

Closed diegovogel closed 3 years ago

diegovogel commented 3 years ago

Hello,

I'm having trouble getting this to work with GitLab. The PUC debugger shows 404's for all requests and I noticed that the URLs are incorrect. The structure should be /projects/:id/repository/ but the URLs requested are something like /projects/:group%2F:repo-name/repository.

Here's a screenshot from the PUC debugger.

Here is what I used to initialize PUC:

require get_stylesheet_directory() . '/lib/plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
    'https://gitlab.com/stablemate/stablemate-wordpress-theme.git',
    __FILE__,
    'stablemate'
);
$myUpdateChecker->setAuthentication('my-access-token');

Any thoughts on what might be causing this?

diegovogel commented 3 years ago

Looks like this may be the culprit. Line 213 in GitLabApi.php:

image

The id is composed of the user name and repo name, but I think the GitLab API requires a numerical repo ID.

YahnisElsts commented 3 years ago

I don't think it has to be numeric, the API documentation says you can use namespaced paths.

Are you sure the repository URL is correct? It probably shouldn't include the .git suffix.

diegovogel commented 3 years ago

Ah, my mistake. It works without .git. Thanks a lot for the quick response!