On my GitHub projects, I've renamed my "master" branches to "main": "main" is the new default branch (and "master" was deleted accordingly).
Since this change, the badge "GitHub combined checks (default branch)" does not work anymore and displays a 522 error.
An example :
https://badgen.net/github/checks/cedx/enum.php
Now, I must add "/main" to the badge URL to fix it:
https://badgen.net/github/checks/cedx/enum.php/main
I'm having a similar issue but adding main doesn't seem to work.
@cedx I'm not sure we would change default branch from "master" to "main", mainly because it's a breaking change. Besides, I think the naming of default branch more depends on git, other than GitHub. Even on GitHub side, a new project's welcome page still recommending git push -u origin master.
@styfle That's a problem, let me check on it
GitHub's API provides the default branch. It's more expensive than just blindly calling master but it's going to work 100% of the time.
I'm also aware of many repositories that have dev (or something similar) as their default repository that's merged into master for many years.
REST v3 https://developer.github.com/v3/repos/#response-5 (default_branch, string)
GraphQL v4 https://developer.github.com/v4/object/repository/#fields (defaultBranchRef, object)
@amio I'm fine with adding /main to my badges. It's just that the wording is misleading: combined checks (default branch) should probably be renamed to combined checks (master branch), and the fact that we can add the desired branch to the URL should be mentioned on the homepage (i.e. add combined checks (branch)).
FYI, GitHub plans to use main in the future for default branch: https://github.com/github/renaming
So assuming master is going to become increasingly more rare in the future
https://github.com/badgen/badgen.net/blob/d190f787b8843155f4e04befcc23aac786c3fcb4/api/github.ts#L99
We might "upgrade" all github badges to use real "default" branch, as @wopian mentioned.
The only use case broken by this change is when someone use /github/checks/:scope/:repo for master branch specifically, while setting default branch to something else. It's rare I guess 馃槃
Most helpful comment
GitHub's API provides the default branch. It's more expensive than just blindly calling
masterbut it's going to work 100% of the time.I'm also aware of many repositories that have
dev(or something similar) as their default repository that's merged intomasterfor many years.REST v3 https://developer.github.com/v3/repos/#response-5 (
default_branch, string)GraphQL v4 https://developer.github.com/v4/object/repository/#fields (
defaultBranchRef, object)