mAAdhaTTah / wordpress-github-sync

A WordPress plugin to sync content with a GitHub repository (or Jekyll site)
https://wordpress.org/plugins/wp-github-sync/
GNU General Public License v3.0
613 stars 99 forks source link

"master" becoming "main" in GitHub causes Not Found error in Github-Sync #211

Closed ilgiocointavolo closed 3 years ago

ilgiocointavolo commented 3 years ago

https://www.zdnet.com/article/github-to-replace-master-with-main-starting-next-month/

All new source code repositories created on GitHub has been named "main" instead of "master" as part of the company's effort to remove unnecessary references to slavery and replace them with more inclusive terms.

Import from GitHub failed with error: Method GET to endpoint https://api.github.com/repos/ilgiocointavolo/articoli/git/refs/heads/**master failed with error: Not Found The new GET method shoud be https://api.github.com/repos/ilgiocointavolo/articoli/git/refs/heads/main**

williambargent commented 3 years ago

I have submitted pull request #212 to fix this issue however in the mean time it is possible to use the WP plugin editor to modify line 141 of lib/client/base.php

FROM: $sync_branch = apply_filters( 'wpghs_sync_branch', 'master' );

TO: $sync_branch = apply_filters( 'wpghs_sync_branch', 'main' );

JonnyTech commented 3 years ago

The change only applies to new repos, existing ones remain unchanged. There is no need for the PR unless you want to copy the branch to main and delete master.

mAAdhaTTah commented 3 years ago

The code snippet you posted also includes a WordPress filter you can use to change the branch, so you can fix this in your own site.