sindresorhus/refined-github

default-branch-button doesn't actually use default branch #3239

DianaNites posted onGitHub

The default branch button normally only appears when you're not currently on the default branch, but github allows repositories to change the default branch, which causes the button to always appear.

Button appears, despite being on the (different) default branch

Screenshot_20200615_214643

No button when on the default branch

Screenshot_20200615_214245

Button when not on the default branch

Screenshot_20200615_214604


We dont check every time you visit a repo if the default branch changed. Since changing a default branch is not a common thing, we check once every 10 days.

Either you can wait for the 10 days or you can clear the cache from the extension options.

posted by yakov116 almost 5 years ago

@fregante I think we should add a detection if the branch is “main” and the default is “master” then re validate. Due to many people changing the master branch to main.

posted by yakov116 almost 5 years ago

Oh, there is a check? Is that documented anywhere?

Clearing the cache did correct the issue, so not a bug I guess. Thanks

posted by DianaNites almost 5 years ago

I think we should add a detection if the branch is “main” and the default is “master” then re validate.

That means "always fetch unless you're on the default branch"

Changing default branch is not a common action so we shouldn't slow down the other hundred thousand "get default branch" requests for that.

What we could do is speed up this getter since it's one of the most common information we use.

For example, when you're on isRepoRoot, you're definitely on the default branch. This means:

If anyone wants to add the first part: https://github.com/sindresorhus/refined-github/commit/1de71bb0a7b1b60d6dd123dd6699f346029399f8

posted by fregante almost 5 years ago

Another detection can be when your on the branches page, the default branch is there.

posted by yakov116 almost 5 years ago

@fregante wasn't this done?

posted by yakov116 almost 5 years ago

Neither one of this is done. This commit hasn't been merged: https://github.com/sindresorhus/refined-github/commit/1de71bb0a7b1b60d6dd123dd6699f346029399f8

See: https://github.com/sindresorhus/refined-github/blob/master/source/github-helpers/get-default-branch.ts

posted by fregante almost 5 years ago
posted by fregante over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests