Refined-github: `default-branch-button` on forks: add secondary button to see folder on source repo

Created on 8 Apr 2020  路  15Comments  路  Source: sindresorhus/refined-github

  1. Visit https://github.com/fregante/refined-github/blob/incremental-tag-changelog-link/source/background.ts
  2. There should be a << link to https://github.com/sindresorhus/refined-github/blob/master/source/background.ts

Example: (ignore the arrow)

How:

  1. Edit the get-default-branch function to accept a user/repo string (and it should only use parseBranchFromDom if the string matches the current page)
  2. Add the button on forks using the CSS code here: https://github.com/sindresorhus/refined-github/pull/1132

More issues semi-related to this one: https://github.com/sindresorhus/refined-github/pull/1115 https://github.com/sindresorhus/refined-github/pull/1168 https://github.com/sindresorhus/refined-github/pull/1557

enhancement help wanted

Most helpful comment

I just realized that Unrelated Feature 馃槃 it exactly this!

Can I have a go for it?

Played around:

Version 1
image

Version 2
image

Version 3
image

All 15 comments

I just realized that Unrelated Feature 馃槃 it exactly this!

Can I have a go for it?

Played around:

Version 1
image

Version 2
image

Version 3
image

Version 4

No extra UI

Edit the get-default-branch function to accept a user/repo string (and it should only use parseBranchFromDom if the string matches the current page)

This is still valid and should be read.

Part of default branch or its own feature?

fork-source-link-same-view

Edit the get-default-branch function to accept a user/repo string (and it should only use parseBranchFromDom if the string matches the current page)

Perhaps we can skip this and keep it simple by using HEAD as previously suggested.

I think so, it kept it very simple and it follows the way we did it for forked to.
However its your call chief

Edit the get-default-branch function to accept a user/repo string (and it should only use parseBranchFromDom if the string matches the current page)

This is still valid and should be read.

i lost you with this one, how would this be different that using HEAD?

Variant 5:

Bildschirmfoto 2020-06-12 um 15 56 32

or with master branch:

Bildschirmfoto 2020-06-12 um 15 59 37

then it is more clear that i can jump to a specific file or i can use the breadcrump higher directory to jump to this directory

because i think the link forked from ..../.... gets a blind spot because i tried it many times, but then i see this link is useless for me in this case to jump to the same file...

gets a blind spot because i tried it many times

Happened to me today while trying out the feature.

In other words you dont realize you changed repo's since the page looks the same.

@fregante what if we add it any only alt?

I made a POC
https://github.com/yakov116/refined-github/tree/fork-source-link-same-view

Variant 5:

I think that will get too noisy on long paths

long path also in a much bigger font above the file, so it is the same "noice" as the file name above the file, but in very small size

I made a POC

This feature is 1 line long. No delegate needed.

const forkSource = select('fork source link')!;
forkSource.pathname = createLink(forkSource.textContent);

... ish, I think you'll need GitHubURL to replace the branch as well

If we change the pathname we mess up this line

export function getForkedRepo(): string | undefined {
-   return select<HTMLAnchorElement>('.fork-flag a')?.pathname.slice(1);
+   return select<HTMLAnchorElement>('.fork-flag a')?.pathname.slice(1).split('/', 2).join('/');
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

vanniktech picture vanniktech  路  3Comments

sindresorhus picture sindresorhus  路  3Comments

mareksuscak picture mareksuscak  路  3Comments

juliocanares picture juliocanares  路  3Comments

mischah picture mischah  路  3Comments