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.26k stars 410 forks source link

Github: name of the default branch changed from master to main #422

Open pixelbart opened 3 years ago

pixelbart commented 3 years ago

First of all, as always, thank you for your work! A great plugin!

Since a few days (4.11) I have to set the branch to main, because apparently master is no longer the default branch in new repositories.

With setBranch('main'); I can counteract this. Possibly the documentation would have to be corrected here. I imagine this to be a bit difficult to integrate, because there seems to be no consistency on the part of Github.

Anyway, now you know.

Thank you and stay healthy everyone!

YahnisElsts commented 3 years ago

Thank you for the notification; I wasn't aware of this change.

There is a way to get the default branch name from the API, but I suspect it's not worth the additional network request. Explicitly setting the branch is probably better for performance. I'll modify the docs to suggest always setting the branch name.

The more serious issue is that the update checker treats master as a special setting that will make it look for releases/tags before using the branch itself. If someone sets any other branch name, PUC won't even check if there are any available releases. I'm not yet sure what a good fix for that would be. Perhaps it can set the branch to NULL by default, but that will be a breaking change. Something to consider.

pixelbart commented 3 years ago

I can't think of a good solution right away, except to ask for both things in the request. I think the note in the docs is sufficient for now, until it has become more standard that the Master Branch is now called Main.

Let's wait and see what will come... I find it a bit strange that it was not openly communicated.

YahnisElsts commented 3 years ago

Regarding your last point, it looks like the change was announced on the GitHub blog. I'm not sure what fraction of GitHub users actually follows that blog, but technically there was a public post about this topic.